Unable to extract JWT Token on request receive

≡放荡痞女 提交于 2021-01-28 11:45:05

问题


I have an architecture which involves two NodeJS microservices. The workflow is as follows:

  • User accesses a URL (localhost:8090) and gets registerd in the database through microservice 1
  • After registration the user is redirected to service 2 which runs on localhost:3000

I'm trying to pass the JWT token from service 1 to service 2 through headers but I'm unable to receive it in service 2 as part of the headers.

Request from service 1 (localhost:8090):

    res.setHeader('Authorization', 'Bearer '+ token); 
    res.redirect(302, `http://localhost:3000`)

Receive at service 2 (localhost:3000):

router.get('/', function(req, res, next) {
  console.log(req.headers);
});

The output of console.log is

{ host: 'localhost:3000',
  accept:
   'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
  'upgrade-insecure-requests': '1',
  cookie:
   'connect.sid=....; csrftoken=...',
  'user-agent':
   '...',
  'accept-language': 'en-us',
  'accept-encoding': 'gzip, deflate',
  connection: 'keep-alive' }

来源:https://stackoverflow.com/questions/65910365/unable-to-extract-jwt-token-on-request-receive

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!