Passport.initialize() middleware not in use Code Example
passport.initialize() middleware not in use
its because you have declared the middleware after you have intialised the routes
in the index file
the correct order is
app.use(passport.initialize());
app.use(passport.session());
app.use(passport.setAuthenticatedUser);
app.use('/', require('./routes'));