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
/profile
On each route where authentication is needed you should apply passport.authenticate middleware i.e :
app.get('/profile', passport.authenticate('local'), (req, res) => { console.log(req.user); console.log(req.isAuthenticated()); }
see Passport documentation