解决方法:
检查是否有jwtFromRequest,没有则添加。
将原本的ExtractJwt.fromAuthHeader()换成ExtractJwt.fromAuthHeaderWithScheme(‘jwt’)
代码示例:
var JwtStrategy = require('passport-jwt').Strategy,
ExtractJwt = require('passport-jwt').ExtractJwt;
var JWT_STRATEGY_CONFIG = {
secretOrKey: SECRET,
issuer : ISSUER,
audience: AUDIENCE,
passReqToCallback: false,
jwtFromRequest:ExtractJwt.fromAuthHeaderWithScheme('jwt')
};