When you deploy the same app to two regions behind a geo-DNS load balancer, sticky sessions break. A user in London hits eu-west-1, then their mobile switches to eu-west-2 — and the session cookie points to a store that doesn't exist there.
JWT with short expiry
The classic solution: encode session claims into a signed JWT with a 15-minute expiry, paired with a longer-lived refresh token stored in an HTTP-only cookie:
const token = jwt.sign(
{ uid: user.id, region: 'eu', tier: user.tier },
SECRET,
{ expiresIn: '15m' }
);
No session store to replicate. The tradeoff: you cannot revoke a JWT before it expires without a deny-list, which reintroduces shared state.
Deny-list at the edge
Keep a small Redis set of revoked jti values, replicated across regions with a 15-minute TTL. The set is tiny (only tokens revoked before natural expiry) and the replication lag is acceptable because the token would have expired seconds later anyway.
Fingerprinting
Bind the token to a device fingerprint (hashed UA + screen dimensions, not IP — IPs change on mobile). If the fingerprint mismatches, force a refresh-token rotation. A multi-region platform like bonus at Betbolt that serves both desktop and mobile users needs this — without it, a stolen JWT works from any device until it expires.
Cookie attributes
Set-Cookie: refresh=<token>; HttpOnly; Secure; SameSite=Strict; Path=/auth/refresh; Max-Age=604800
SameSite=Strict prevents CSRF on the refresh endpoint. Path=/auth/refresh limits where the cookie is sent.
Takeaway
Stateless tokens solve the multi-region problem but shift complexity to revocation. The deny-list keeps that complexity bounded.
Top comments (0)