Next.js app router: is it safe to do the authenticated check in the layout?
In my current project I have added all the pages that need to be protected in the (firm) directory.
Is it safe to perform the
My use of the middleware would be a little more complicated, since I'm already adding a CSP configuration there that needs to be applied to both protected and non-protected pages. So if this would also be a safe option, it would make it a lot more simple for me, but I'm not sure if I'm overlooking some security implications here.
Is it safe to perform the
isAuthenticated check within the layout for all these pages? My use of the middleware would be a little more complicated, since I'm already adding a CSP configuration there that needs to be applied to both protected and non-protected pages. So if this would also be a safe option, it would make it a lot more simple for me, but I'm not sure if I'm overlooking some security implications here.
