Help with authentication
Unanswered
Common House-Martin posted this in #help-forum
Common House-MartinOP
hello, I made a backend in nestjs for my custom app and I have a problem. I made the route /users/login that returns the JWT token and now I want to make it so I can protect routes and get the payload from inside my components/pages in next. The problem is that I can't add a middleware because that's client sided and I can't get the token that I stored on localstorage. What would be the best way to setup my project to support this type of authentication? I'm using next 13 with app folder
1 Reply
Aleutian Tern
If you want to want stays only using Client Component your best bet is use a Context to handle the authentication. Otherwise, you could set a cookie and use the middleware to handle the authentication.