Passport.js redirects to |successRedirect: '/profile'| but req.isAuthenticated() returns false
问题 The following code is a section of an app developed by Node.js + Express + Passport.js. A valid user gets redirected to /profile url (successRedirect), however the req.isAuthenticated returns false and also the req.user is undefined . I couldn't figure out what might be the cause: app.post('/login', passport.authenticate('local', { successRedirect: '/profile',// <-- a valid user gets redirected to `/profile` failureRedirect: '/', failureFlash: true }) ); app.get('/profile',function(req,res){