Here is the user requested for /dashboard route, then firstly a gerServerSideProp function will fire and check the authentication-token cookie sent by the browser and if the token is valid then the route is allowed otherwise it is routed to the home page.
Just wanted to know is there any better way of doing it, coz it takes some time for validating the token, and also this code has to be implemented to every protected route.
CodePudding user response:
I think NextAuth is the best choice to make an authentication app. It maybe can solve your question.
Here is an example of the usage of NextAuth.