Next-Auth issue
Unanswered
Masai Lion posted this in #help-forum
Masai LionOP
Here's what i am going through:
you submit the sign in form
the signIn server action from next-auth is redirecting to '/' by default when no redirectTo is specified
importantly: at this point, the router has already received a response from the server, indicating it's on the '/' page.
Next.js will fire off an intra-app request to '/' since that's what the redirect told it to do, but because the user is now authenticated, but in my middleware i call a redirect to instead forward the request to '/protected'
The signIn request to '/' returns the page data for '/protected', hence the UI updating, but not the URL.
How can i fix this?
you submit the sign in form
the signIn server action from next-auth is redirecting to '/' by default when no redirectTo is specified
importantly: at this point, the router has already received a response from the server, indicating it's on the '/' page.
Next.js will fire off an intra-app request to '/' since that's what the redirect told it to do, but because the user is now authenticated, but in my middleware i call a redirect to instead forward the request to '/protected'
The signIn request to '/' returns the page data for '/protected', hence the UI updating, but not the URL.
How can i fix this?
6 Replies
Asiatic Lion
Would you like to provide your
middleware.ts that could help to investigate why URL update doesn't happen?Masai LionOP
Here
actually the redirect happened, just that is not updating the url
@Asiatic Lion here is the specific part where redirect happened
The page is rendering fine, just that the url is not updated still showing '/' instead of the path i want it to go to which the content is already rendered
Masai LionOP
I still need help with this