Next.js Discord

Discord Forum

NextJs Middleware for Simple JWT Cookie Token validation

Unanswered
Ejayz || PiggyDev posted this in #help-forum
Open in Discord
So i want to validate some routes and see if there is a cookies and this cookies are valid. If not then i can reroute them to login page.

3 Replies

European pilchard
You would probably just need to do an if statement to check if the cookie exists/is valid in the middleware.ts. Also need a matcher for the middleware to trigger on the specific routes you want. However, there seems to be an issue with too many redirects in the middleware feature since it currently triggers multiple times per route. This has not been answered yet and I have not found a solution. If you find different results please post as there are other people with the same issue
Britannia Petite
might help you