Express Sessions not working #11565
Replies: 1 comment 1 reply
-
It seems you are experiencing issues with session persistence in your Vercel Express application. The session ID changing with every page jump is indeed indicative of serverless environments where instances may not maintain state between requests. Using MongoDB as a session store should have helped with this issue, but if sessions are not being recognized, it could be related to a configuration or deployment issue. There are suggestions that involve checking the trust proxy setting in Express when behind proxies, which is common in serverless deployments like Vercel. This setting is crucial for secure cookie handling. https://stackoverflow.com/questions/65767024/express-session-not-working-in-production-deployment Additionally, ensuring that your code is optimized and using caching can help with serverless function timeout errors. https://devcodef1.com/news/1088606/vercel-serverless-function-timeout-errors Here are some steps you could consider:
If you have already tried these steps or if they do not resolve the issue, it may be beneficial to reach out to someone with specific expertise in Vercel deployments or Express session management. |
Beta Was this translation helpful? Give feedback.
-
Question
I have a checkout flow on vercel which was working fine and now when a customer jumps from one page to another all the req.session gets lost. I noticed that the session ID changes everytime, I know this happens because of the serverless. Although I had contoured this problem using MongoDB as a storage, it came back because it doesn't recognize the session to retrieve the data.
This is my express session settings, when I first have this problem I solved changing sameSite to none, right now I don't have any clue why this is happening again
Beta Was this translation helpful? Give feedback.
All reactions