Problem Statement
Which JWT practice is most important for API safety?
Explanation
A JWT is only useful if you verify it correctly. Check the signature with the correct key from the trusted issuer. Confirm the audience, issuer, and time based claims. Reject tokens with unexpected alg values. Do not accept unsigned tokens.
Keep tokens short lived. Rotate signing keys with a J W K S endpoint when possible.
Code Solution
SolutionRead Only
verify(jwt, { issuer: 'https://auth.example', audience: 'api', algorithms: ['RS256'] })