mhkeller
mhkeller

Reputation: 712

expressJS creates new session every page load

Running locally everything is fine but when I deploy my app using vagrant to a virtual box or to amazon and put it behind nginx, redirects and page loads refresh req.session.

Here's the nginx configuration: https://github.com/newslynx/automation/blob/master/provisioning/templates/app-nginx.conf.j2

And how I'm setting up my session store in the Express app: https://github.com/newslynx/newslynx-app/blob/master/lib/app.js

And where I'm setting the apikey and org ids on the session, which are getting cleared when the user gets redirected to '/' https://github.com/newslynx/newslynx-app/blob/master/lib/routes/organizations.js#L55-L65

I've tried combinations of saveUninitialized and resave to true and false. I've switched to in-memory as well as Redis-backed session store with no change. I'm stumped.

Upvotes: 2

Views: 687

Answers (1)

mhkeller
mhkeller

Reputation: 712

This problem was due to the app being loaded in an https context and thus not setting cookies over http. This answer has more detail: Session variables not being set in expressjs

Upvotes: 1

Related Questions