HTTP Strict Transport Security (HSTS)
Tell browsers to use HTTPS for your site every time, so nobody can downgrade a visitor to plain HTTP.
What it is
The Strict-Transport-Security header makes the browser remember, for the time you set, that your site must only be loaded over HTTPS.
Why it matters
Without it, an attacker on the network can intercept a visitor's very first plain-HTTP request and keep them on an unencrypted copy of your site.
How to fix it
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains"
SSL/TLS > Edge Certificates > HTTP Strict Transport Security (HSTS): Enable
import helmet from "helmet"; app.use(helmet()); // sets HSTS and other safe defaults
async headers() { return [{ source: "/:path*", headers: [ { key: "Strict-Transport-Security", value: "max-age=31536000; includeSubDomains" }, ] }]; }
Only add includeSubDomains once every subdomain works over HTTPS. Start with a shorter max-age (for example 300) if you are unsure, then raise it.
Does your site have this problem?
Kompile Scan checks for this and the other problems in these guides in under a minute. Free for one site.