Node.js JwtStrategy需要一个函数来从请求中检索JWT

Node.js JwtStrategy需要一个函数来从请求中检索JWT,node.js,jwt,passport.js,Node.js,Jwt,Passport.js,当我试图从授权标头提取JWT令牌时,我遇到以下错误: TypeError: JwtStrategy requires a function to retrieve jwt from requests (see option jwtFromRequest) at new JwtStrategy (C:\MEANauth app\node_modules\passport-jwt\lib\strategy.j s:55:15) at module.exports (C:\MEANauth app\

当我试图从授权标头提取JWT令牌时,我遇到以下错误:

TypeError: JwtStrategy requires a function to retrieve jwt from requests (see 
option jwtFromRequest)
at new JwtStrategy (C:\MEANauth app\node_modules\passport-jwt\lib\strategy.j
s:55:15)
at module.exports (C:\MEANauth app\config\passport.js:10:15)
at Object.<anonymous> (C:\MEANauth app\app.js:37:29)
at Module._compile (module.js:643:30)
at Object.Module._extensions..js (module.js:654:10)
at Module.load (module.js:556:32)
at tryModuleLoad (module.js:499:12)
at Function.Module._load (module.js:491:3)
at Function.Module.runMain (module.js:684:10)
at startup (bootstrap_node.js:187:16)
at bootstrap_node.js:608:3
app.js:这是主文件

const passport =require("passport");
这是护照

//passport middleware
app.use(passport.initialize());
app.use(passport.session());
//这是它指向错误的语句

require('./config/passport')(passport);

只需在
opts.JwtFromRequest
中将“J”改为“J”:

opts.jwtFromRequest =ExtractJwt.fromAuthHeaderWithScheme("jwt");
opts.jwtFromRequest =ExtractJwt.fromAuthHeaderWithScheme("jwt");