Server storage
Answered
Polar bear posted this in #help-forum
Polar bearOP
I'm learning Next.JS and I need to store JWT token (which I get from ASP.NET API) on server. Are there any storages for server? I don't want to make components as client.
My idea is to match user session ID with JWT token and store it on server.
My idea is to match user session ID with JWT token and store it on server.
8 Replies
@Polar bear I'm learning Next.JS and I need to store JWT token (which I get from ASP.NET API) on server. Are there any storages for server? I don't want to make components as client.
My idea is to match user session ID with JWT token and store it on server.
save the jwt in cookies and then access that in your server components
@@ts-ignore save the jwt in cookies and then access that in your server components
Polar bearOP
Isn't it dangerous to store JWT token as cookie?
You save non sensitive information in a jwt(I personally save the id of the user) and then verify the token server side to get the user object
Polar bearOP
I heard about httpOnly cookies but not sure if Next.JS supports it... Have to check it
Answer
check the code example
Polar bearOP
Thanks!