Add the Strict-Transport-Security (HSTS) header on Vercel
Why it matters
Without HSTS, a browser that is sent to the http:// address first can be intercepted before it reaches the secure site. The header tells browsers to use HTTPS only, for as long as you specify.
Staged change. Do this in stages and check each one before the next, so a mistake does not break your site or your mail.
The fix
- Vercel is HTTPS-only and sends Strict-Transport-Security with a max-age of two years on custom domains by default, so a missing header means this host is not served directly by Vercel (a proxy in front may strip it) or the project overrides it.
- To set it explicitly, add a headers rule to vercel.json and redeploy. Start with the short value, then raise it.
vercel.json
{ "headers": [ { "source": "/(.*)", "headers": [ { "key": "Strict-Transport-Security", "value": "max-age=300" } ] } ] }
Related
- Reported by the HSTS check
- Fix the malformed Strict-Transport-Security header
- Re-enable HSTS (max-age is zero)
- Raise the HSTS max-age
- Decide whether to add includeSubDomains
- Meet the HSTS preload requirements or remove preload
- Consider submitting the domain to the HSTS preload list
- Send HSTS on the redirect visitors meet first
Scan your domain to see whether this applies to you.