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
}));