Server/main.js Routes

0
open
carloquilala
carloquilala
Posted 3 years ago

Server/main.js Routes #1348

Can someone please enlighten me, I'm currently adding routes in my app, and I want to get the req.session to work also in production build but it returns null

Production using script "cross-env NODE_ENV=production pm2 start server/main.js --name ucf-www"

app.post('/api', bodyParser.json(), (req, res) => {
  const nodeSession = req.session;
  console.log(nodeSession)

  // undefined
})

Development using script "cross-env NODE_ENV=development babel-node build/scripts/start"

app.post('/api', bodyParser.json(), (req, res) => {
  const nodeSession = req.session;
  console.log(nodeSession)

  /*
    Session {
      cookie: {
        path: '/',
        _expires: null,
        originalMaxAge: null,
        httpOnly: true
      }
    }
   */
})

please delete, just forgot to use express-session in my production config