Next.js Discord

Discord Forum

How to decode next-auth session cookie at the backend?

Unanswered
European sprat posted this in #help-forum
Open in Discord
European spratOP
I've a next.js frontend application with next-auth and a nest.js serving backend.
I had to establish a websocket connection from a client component, I don't want to expose my access tokens and I guess you would agree with that too. With that, When I send a websockt client it sends the next-auth cookie in the hrrp headers. how can I decode the cookies at backend?

any answers are appreciated

3 Replies

Spectacled bear
I'm not sure but you can look at next auth implementation of getToken() function for reference. Generally, it is difficult to decode next-auth token in external servers.
European spratOP
it's of no use.
It is basically to to get token back within the api routes.