Strict-Transport-Security (HSTS) header
HSTS tells a browser to only ever connect over HTTPS. Here's what it protects against, and the exact header config to add it.
What it is
Strict-Transport-Security (HSTS) is a response header that tells a browser to only ever connect to this host over HTTPS, for a duration set by max-age, without first trying HTTP.
Once a browser has seen the header, it rewrites http:// requests to https:// itself, before any network request is sent — the redirect never has to happen over the wire.
Why it matters
Without HSTS, every visit that starts by typing a bare domain or following an http:// link makes one plaintext request before any redirect happens. That's the exact window an on-path attacker — a hostile Wi-Fi network, a compromised router — needs to intercept or downgrade the connection.
HSTS closes that window for anyone who has already visited once, and includeSubDomains extends the same protection to every subdomain without a separate header on each.
How to fix it
with a reference docadd_header Strict-Transport-Security "max-age=15768000; includeSubDomains" always;Header always set Strict-Transport-Security "max-age=15768000; includeSubDomains"async headers() {
return [{
source: '/(.*)',
headers: [{ key: 'Strict-Transport-Security', value: 'max-age=15768000; includeSubDomains' }]
}];
}/*
Strict-Transport-Security: max-age=15768000; includeSubDomainsRelated checks
4This is one of the 75 checks the scanner runs. See what we check for the full list, every severity weight, and how the score is computed from them.