DEV Community

Discussion on: Redirects in Next.js, the Best Way

Collapse
 
benriga profile image
Ben Riga

@sergiodxa I tried this on a sample project and noticed something odd. If I go to the PrivatePage while not logged in then it redirects me to the Login page with the right url in the browser (i.e. /login). That is all good.

But once I login in then I am redirected back to PrivatePage but the url in the browser still says /login. Any thoughts on how you might solve that?

This seems like it might get repetitive if you have a lot of private pages. Is there a way to componentize this?

Thanks,
Ben