Avoid user access by directly typing url NEXT js

106 Views Asked by At

I currently build an app with Next and React. I have routes like /checkout or /checkout/success that I do not want letting the user directly acessing to it by typing the url in the search bar

I want force the user to navigate along pages manually to acces to these routes but I have no idea how to do it.

Thanks in advance for your help !

1

There are 1 best solutions below

2
Aditya Chebrolu On

On the server side code, check whether the user is authenticated or not. If the user is authenticated, then the flow is as usual if not, then redirect him to login page.