I'm new to node.js and am trying to figure out how to implement express-sessions with my single page app.
The node.js server is deployed using google cloud app engine.
The single page app is deployed using Netlify and calls the node.js server for all data fetch calls.
I'm using express-session
I'm able to create a session at /login session but future fetch calls (/home) aren't persisting session data.
I'm looking for someone to pair with / help unblock.
Thanks!
Is your session token being stored in a cookie? Are you using the
fetch()
function rather than the older XMLHttpRequest? If so, I would check your fetch calls since it doesnt send cookies by default like an XHR does, so that could be your issue.https://stackoverflow.com/questions/34558264/fetch-api-with-cookie
Hard to say without looking at the code, if I had to guess there's probably an issue with your CORS (+ security) headers and possibly cookie management. Honestly this is the exact reason why session management SaaS providers like Authress exist, but I know it's tempting to try to write something "simple" because it's cheaper.
My first suggestion would be to paste your issue on Stack Overflow and see if you get any hits, including code examples of course ;), with the alternative being pull in a login/session management solution, they are fairly good value for the money.