Trying to implement JWT authentication in node. Getting unauthorized in protected routes

后端 未结 2 1547
广开言路
广开言路 2021-01-24 18:55

I am trying to implement JWT authentication. /login and /register work fine and they return authentication token, but when I try to GET /secret with a header \'Authorization\' =

2条回答
  •  清歌不尽
    2021-01-24 19:45

    opts.jwtFromRequest = ExtractJwt.fromAuthHeaderAsBearerToken();
    

    should be

    ExtractJwt.fromAuthHeaderWithScheme('jwt');
    

提交回复
热议问题