Is is possible to use express-session for cookie-based authentication? #257
-
I have a NestJS server and an Apollo client with |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 12 replies
-
Cookies are automatically added to the headers of WebSocket HTTP upgrade requests by the browser. Authenticate the client the same way you would a regular HTTP request. A great place to do auth is in the |
Beta Was this translation helpful? Give feedback.
-
Hey, I think I have quite a similar setup. In the background I use express-session but have no idea how to access the session object. I know that my session store executes the reuest correctly, but the response can't be found in the onConnect's context. |
Beta Was this translation helpful? Give feedback.
Cookies are automatically added to the headers of WebSocket HTTP upgrade requests by the browser.
Authenticate the client the same way you would a regular HTTP request. A great place to do auth is in the
onConnect
callback, you may find the HTTP upgrade request in thectx.extra.request
.