1

Description I'm currently trying to implement some session authentication logic in my node backend, but having issues in my development environment that I can't seem to troubleshoot.

Backend: node with express Library: cookie-session

Link to documentation: https://www.npmjs.com/package/cookie-session

Setup Running server in an EC2 instance (not secure). However pointing ngrok proxy server over https at ec2 instance.

server.js

app.use(cors({ origin: true, credentials: true }));
app.use(cookieParser());
app.set('trust proxy', true);

app.use(cookieSession({
  keys: ['veryimportantsecret'],
  name: "session",
  cookie: {
    httpOnly: true, 
    sameSite: 'none', 
    secure: true
  }
}))

app.use(function (req, res, next) {
  console.log('req.session', req.session.testing) // logs undefined on each request
  req.session.testing = (req.session.testing || 1) + 1;
  next();
});

Expected Behavior Session ID to deserialize and provide last request value of testing on session property.

Current Behavior Nothing is set on session

0 Answers0