The app supports dual-secret JWT verification to allow zero-downtime secret rotation.
JWT_SECRET— the current signing secret (required)JWT_SECRET_PREVIOUS— the previous secret, accepted during the overlap window (optional)
- Token verification tries
JWT_SECRETfirst. - If verification fails and
JWT_SECRET_PREVIOUSis set, it retries with the previous secret. - Tokens verified via the previous secret are transparently re-issued using
JWT_SECRETand returned in theX-Refreshed-Tokenresponse header.
- Set
JWT_SECRET_PREVIOUSto the current value ofJWT_SECRET. - Generate a new secret and set it as
JWT_SECRET. - Deploy. Existing sessions continue to work via
JWT_SECRET_PREVIOUS. - After your session TTL has elapsed (all old tokens expired), remove
JWT_SECRET_PREVIOUS. - Deploy again to complete the rotation.