nestjs-api-tutorial
nestjs-api-tutorial copied to clipboard
Code in the jwt.strategy.ts file is not working properly
I am creating this issue just in case if someone is following the nodejs tutorial on freecodecamp and facing issue while implementing the JWT strategy.
https://github.com/mikenicholson/passport-jwt/issues/153
export class JwtStrategy extends PassportStrategy(Strategy) {
constructor(private configService: ConfigService) {
super({
secretOrKey: configService.get('JWT_SECRET'),
jwtFromRequest: ExtractJwt.fromAuthHeaderWithScheme('Bearer'), //instead of ExtractJwt.fromAuthHeaderAsBearerToken()
ignoreExpiration: true,
});
}
validate(payload: any) {
console.log(payload);
return payload;
}
While calling the request you can normally pass Authorization header as Bearer ${token}