Render session problem

I have a web project (Next.js + Node.js). I deployed the Node.js application on Render and then tried to connect from my locally running Next.js application. When I try to log in, it logs in, but when I query the logged-in user on the home page, req.session.userID becomes null. I tried session stores (connect-mongo, connect-mongodb-session), but they didn’t work.

From what I understand, Render has an issue with sessions, not saving previous operations.

app.use(session({
secret: ‘my_secret’,
cookie: {
httpOnly: true,
secure: true,
sameSite: ‘none’ },
domain: “http://localhost:3000/”,
store: MongoStore.create({ mongoUrl: “mongodb+srv://tgokceer:*****@cluster0.plwkuyo.mongodb.net/”}) ,
resave: true,
saveUninitialized: true
}));

Hi there,

See if it helps if you add app.set('trust proxy', true) so Express trusts our proxy. Also, make sure the cookie is set correctly on your browser.

Regards,

Keith
Render Support, UTC+10 :australia:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.