Skip to content

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

@amuthansakthivel

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}

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