Fix · Express / Node
Fix “HTTP Strict Transport Security (HSTS)” on Express / Node
Add: Strict-Transport-Security: max-age=63072000; includeSubDomains; preload
res.setHeader("Strict-Transport-Security", "max-age=63072000; includeSubDomains; preload");
Verify the fix
Re-run the HTTP Strict Transport Security (HSTS) check after deploying. Test config changes in staging first and keep a rollback: a wrong header can break a site faster than a missing one.
Other stacks: nginx · Apache · Caddy · Cloudflare