问题
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