'How to get a JWT token from one server to another in order to validate APIs which is running on different ports in node & express?
I have two modules in two different server i.e., User and transaction module.
User module has one Login API which generates the JWT token, Now I want to send that token to transaction module server and verify in order to protect routes.
Please suggest some ways how should I approach this scenario?
Solution 1:[1]
with JWT, it has a secret key, u just share this to two modules, and use this.
Solution 2:[2]
The easiest approach would be to share that secret_key to that "transaction module server" and verify the requests with same secret_key on both servers.
If you don't want to share the secret_key with the other server, then you have to sign the tokens with RSA.
With RSA, there is a concept of Private and Public key.
You sign the key with secret that is private and kept secure on your server and you share the public_key with all other servers, they can use this public_key to verify your signature.
Here's some articles on it -
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Nhut Pham |
| Solution 2 | Adarsh Chakraborty |
