Skip to content Skip to sidebar Skip to footer

ExpressJs Passportjs De-serializes User Object For Every Request To A Route

I have a ExpressJS app that is using Passportjs to authenticate with Facebook and everything is working as expected exception for one issue. I have vehicle.js under /routes/ which

Solution 1:

You can wrap the passport middleware inside a custom middleware that only invokes it for your specified routes. So Instead of:

app.use(passport.session());

you could:

app.use(function(req, res, next){
  if(req.url.match('api/image'))
    next(); // do not invoke passport
  else
    passport.session()(req, res, next)
    // same as doing == app.use(passport.session())
});

Solution 2:


Post a Comment for "ExpressJs Passportjs De-serializes User Object For Every Request To A Route"