You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Whenever I make the request with postman with the bearer token feature, it works and I get access to the route, but when I am trying to do it out of postman, on my browser, it does not work and I only get "Unauthorized"
Passport.js
const options = {
jwtFromRequest:ExtractJWT.fromAuthHeaderAsBearerToken(),
secretOrKey:jwtSecret.secret
};
passport.use(
'jwt',
new JWTStrategy(options,(jwt_payload,done)=>{
console.log('jwt from request '+options.jwtFromRequest);
try{
User.findOne({
where:{
id:jwt_payload.id
},
}).then(user=>{
if(user){
console.log('User found in DB in passport')
done(null,user)
}else{
console.log('User not found in db');
done(null,false)
}
});
} catch(err){
done(err)
}
})
)
Login Route ;
notice that I am doind a res.set to set the header as authorization: 'bearer ' + token to set the header. It sets the header, but when I try to access the protected route, the passport jwt does not seem to get the header value or something like it
Authorization is a request header, not really valid in the response. So your browser is probably not sending back an Authorization header just because you sent it in the previous response.
Closing as Github issues are not the right place for this kind of request. Please use issues for bugs or problems with the functionality of this module. For help with implementation or debugging consider stack overflow or the many tutorials available.
Whenever I make the request with postman with the bearer token feature, it works and I get access to the route, but when I am trying to do it out of postman, on my browser, it does not work and I only get "Unauthorized"
Passport.js
Login Route ;
notice that I am doind a res.set to set the header as authorization: 'bearer ' + token to set the header. It sets the header, but when I try to access the protected route, the passport jwt does not seem to get the header value or something like it
I dont think that is relevant to mention it here, but the route that I am trying to access is this one:
TL;DR: Cant have access to protected route in my browser, but when I do the request with postman it works!
The text was updated successfully, but these errors were encountered: