How to make RootLayout private? (All pages private, redirect to /signin)
Answered
English Angora posted this in #help-forum
English AngoraOP
Heeyyyy everyone,
I am trying to make everything private, including the RootLayout and it's page, I tried to make the RootLayout private in the way this happens with the already private pages in app, but this crashed my website.. 😅
So I have a redirect after /signin that works, but I would like to have everything private even the
Or would you advise something else?
I use Supabase for auth.
When I do this I receive a: ERR_TOO_MANY_REDIRECTS in my browser.
I would love to know what I should do to make this happen.
Thank you in advance!
I am trying to make everything private, including the RootLayout and it's page, I tried to make the RootLayout private in the way this happens with the already private pages in app, but this crashed my website.. 😅
So I have a redirect after /signin that works, but I would like to have everything private even the
/ RootLayout, so everything /signin is the firstpage, and from there you get redirected to /.. Is this possible?Or would you advise something else?
I use Supabase for auth.
When I do this I receive a: ERR_TOO_MANY_REDIRECTS in my browser.
I would love to know what I should do to make this happen.
Thank you in advance!
Answered by joulev
So you can only do the auth check + redirection in the (app) and (onboard) layouts. Doing it in app/layout.tsx won’t work
4 Replies
@English Angora Heeyyyy everyone,
I am trying to make everything private, including the RootLayout and it's page, I tried to make the RootLayout private in the way this happens with the already private pages in app, but this crashed my website.. 😅
So I have a redirect after /signin that works, but I would like to have everything private even the `/` RootLayout, so everything `/signin` is the firstpage, and from there you get redirected to `/`.. Is this possible?
Or would you advise something else?
I use Supabase for auth.
When I do this I receive a: ERR_TOO_MANY_REDIRECTS in my browser.
I would love to know what I should do to make this happen.
Thank you in advance!
The root layout also covers /sign-in so you got yourself to a redirection infinite loop.
Use route groups to instead create another layout for all non-signin pages and do the redirection there.
See also: [auth in layouts is insufficient](https://github.com/eric-burel/securing-rsc-layout-leak)
Use route groups to instead create another layout for all non-signin pages and do the redirection there.
See also: [auth in layouts is insufficient](https://github.com/eric-burel/securing-rsc-layout-leak)
@joulev The root layout also covers /sign-in so you got yourself to a redirection infinite loop.
Use route groups to instead create another layout for all non-signin pages and do the redirection there.
See also: [auth in layouts is insufficient](<https://github.com/eric-burel/securing-rsc-layout-leak>)
English AngoraOP
Hi, thank you for your quick reply!
Ahh, hence the redirection error.. I do use Route groups, I should check what is going wrong here.
The signin does have a different layout, though?
Ahh, hence the redirection error.. I do use Route groups, I should check what is going wrong here.
The signin does have a different layout, though?
@English Angora Hi, thank you for your quick reply!
Ahh, hence the redirection error.. I do use Route groups, I should check what is going wrong here.
The signin does have a different layout, though?
So you can only do the auth check + redirection in the (app) and (onboard) layouts. Doing it in app/layout.tsx won’t work
Answer
@joulev So you can only do the auth check + redirection in the (app) and (onboard) layouts. Doing it in app/layout.tsx won’t work
English AngoraOP
Hmmm, okay. Thank you!