Skip to content

Code in the jwt.strategy.ts file is not working properly #21

Description

@amuthansakthivel

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.

mikenicholson/passport-jwt#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}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions