How to access in node.js?


I am newbie to the node.js world. I am using passportjs library for authenticating the user with api key. What I am trying to do is that along with api key. I also want to check the host name of the request.'/api/authenticate', 
  passport.authenticate('localapikey'),//passport module method to authenticate the api key
  function(req, res) {

I don't know how passportjs calling the below function. But it definitely calling the function after a post request is coming to the path '/api/authenticate'. I also want to access the in the below function.

passport.use(new LocalStrategy(
  function(apikey, done) {

Is it possible? Any insight into this would highly be appreciated. Thank you.

Problem courtesy of: Jetson John


Use the passReqToCallback option. See the bottom of this page for details:

You must update your code like this:

passport.use(new LocalStrategy({
    passReqToCallback: true
  function(req, apikey, done) {

Solution courtesy of: user1218070


There is currently no discussion for this recipe.

This recipe can be found in it's original form on Stack Over Flow.