Next.js Discord

Discord Forum

Redirect after Login with two RootLayouts

Unanswered
Harlequin posted this in #help-forum
Open in Discord
HarlequinOP
Hi guys,

i am working with two rootlayouts, so my folder structure looks like this:

/app/(webapp)/app/dashboard/
/app/(website)/login/


Now my log-in page (server component) resides of course in website because its unprotected. I do my auth with a server action embedded in the server component. After i am done authenticating, i want to redirect() to "/app/dashboard".

Problem is, he tries the redirect but it looks like the layout switch' page reload will win this battle and i keep being on the login page.

Now i wonder how other people solve this. I can imagine that i am not the only one with the idea to have Route groups for the public website and the webapp with hundreds of protected routes.

Thanks for insights.

1 Reply

HarlequinOP
Answer to /myself : Its because of this bug: https://github.com/vercel/next.js/issues/58263