← All guides
Medium Reported as: Strict-Transport-Security header missing

Missing HSTS header (Strict-Transport-Security)

What HSTS does, why an HTTPS site without it can still be downgraded, and the exact header to set on Nginx, Apache, Vercel, Netlify and Cloudflare.

HTTPS protects a connection once it is made. HSTS tells the browser to always use HTTPS for your site, so an attacker on the same network cannot strip it down to plain HTTP on the first request.

The header

Strict-Transport-Security: max-age=31536000; includeSubDomains

Start with a short max-age (for example 300) while you confirm everything on the domain works over HTTPS, then raise it to a year. Add preload only when you are sure: a preloaded domain is hard to take back.

Where to set it

HostHow
Nginxadd_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
ApacheHeader always set Strict-Transport-Security "max-age=31536000; includeSubDomains"
Vercelvercel.json, under headers, source /(.*)
Netlifya _headers file, or [[headers]] in netlify.toml
CloudflareSSL/TLS, Edge Certificates, HTTP Strict Transport Security
Next.jsheaders() in next.config

The header is ignored over plain HTTP, so it only counts on your HTTPS responses.

Last reviewed 2026-09-26