bim
08/14/2021, 4:52 AMProtectedRoute
component that checks if there is a user logged in and whether the path is protected, and will router.push
to /login accordingly.
The issue im having is that after await supabase.signIn()
is called, I’m being redirected to my homepage, but after the redirect supabase.auth.user()
is still null
, and my ProtectedRoute
component is then redirecting back to /login. If I enter the url to go to the home page again, it won’t redirect me and user
is no longer null
.
In other posts I saw onAuthStateChange
suggested to be used. But I am already using an AuthProvider similar to the examples that utilise onAuthStateChange
. I think in my case it may be that the change in path is triggering a redirect before the user state is changed. But I'm not sure how to fix this.
I see in a few examples people redirect with getServerSideProps. But if I did this, wouldn't all of my pages would go from client side rendering to SSR, and I’m not sure if that would benefit me since I'm not interested in SEO. Although I’m not a fan of the loading page flash that occurs when a protected route is being client side redirected to the login page.silas
08/18/2021, 6:22 AMsilas
08/18/2021, 6:22 AM