Next.js Discord

Discord Forum

How to handle authentication in a Next.js application without saving data in cookies

Unanswered
Australian Freshwater Crocodile posted this in #help-forum
Open in Discord
Australian Freshwater CrocodileOP
Hi, I have a Next.js application. I need to set up authentication data in the middleware, but I don't want to store the value in cookies. What are my other options?

3 Replies

@Australian Freshwater Crocodile Hi, I have a Next.js application. I need to set up authentication data in the middleware, but I don't want to store the value in cookies. What are my other options?
You don’t have any other options, given the constraints. The only thing the middleware can access is the request, in which the cookies are the only place where you can store authentication data for the browsers to automatically attach to every request
Perro Majorero
JWT in local storage didnt read middleware as requirement sorry
Red-tailed wasp
hey, following on this topic. i'm doing a feature whitelist on per-user basis and need the middleware to block unauthorized page redirects. is it fine to store some data about them on cookies?