I am facing the issue : on every request new sessionID is getting created. Can someone throw light at this ?
Versions I am using:
NODE VERSION: v6.10.3 NPM VERSION: 3.10.10 [email protected] [email protected]
Also what is the default value for maxAge if I am not setting the cookie specifically ? Not sure if its required.
Do you see any issue with the code below ? Please assist as I am stuck.
var app = express();
app.use(express.static(path.join(__dirname, 'landing')));
app.use(bodyparser.json());
app.set('trust proxy', 1) // trust first proxy
app.use(session({
secret: 'keyboard cat',
resave: false,
saveUninitialized: true,
cookie: {secure: true}
}))
app.get('/', function (req, res) {
res.sendFile(path.join(__dirname, 'landing', 'index.html'));
});
var contextPath = '/myportal';
//UI url
app.get(contextPath, function (req, res) {
var reqValues;
logger.info("req sessionID is :::" + req.sessionID);
// do something
}
app.use(express.static(path.join(__dirname, 'build'))); //react UI path
res.sendFile(path.join(__dirname, 'build', 'index.html'));
}
//health check url
app.get(contextPath + '/health', function (req, res) {
logger.info("env is " + env);
logger.info("myportal health is ok");
res.send('Health Ok!\n');
});
https
-express. – Woodsman