Using Passport JWT Strategy, I'm passing the token down via params, and extracting the token like this ExtractJWT.fromUrlQueryParameter('secret_token').
But sometimes I'm passing the token down via header, I would like to extract it like this ExtractJWT.fromHeader('secret_token').
How can I check how its being passed down and use the correct extracting method dynamically.
This is my code:
passport.use(new JWTstrategy({
secretOrKey: process.env.AUTH_SECRET,
jwtFromRequest: ExtractJWT.fromUrlQueryParameter('secret_token')
}, async (token, done) => {
try {
//Pass the user details to the next middleware
return done(null, token.user);
} catch (error) {
done(error);
}
}));
Thank you! Im on this for a long time....