Security headers

HTTP response headers that tell the browser to be stricter: force HTTPS, block framing, restrict scripts, stop leaking referrers.

those headers scanners yell aboutHSTS and friendshttp security headersthe headers that get you an A on that scan sitesecurity response headershsts csp x-frame-optionsheaders to stop clickjackingsecurityheaders.com grade

See it

Live demo coming soon

What it is

Security headers are HTTP response headers that ask the browser to behave more strictly on your site. The set worth knowing: Strict-Transport-Security (never speak plain HTTP to this domain again), Content-Security-Policy (only load scripts and resources from this allowlist, which is the one that actually blunts XSS), X-Content-Type-Options: nosniff (do not guess file types), Referrer-Policy (stop leaking full URLs to other sites), Permissions-Policy (nobody here needs the camera), and the cross-origin trio COOP, COEP, and CORP for isolating your page from other origins. X-Frame-Options is the old clickjacking defense, now superseded by CSP frame-ancestors, and X-XSS-Protection is dead: modern browsers ignore it, so delete it.

They cost nothing to add, which is why they are a standard hardening pass. Set them once at the edge (CDN, reverse proxy) or in framework middleware so every route inherits them, rather than sprinkling them per handler. Then check the result with a scanner and with your browser console, not with your intentions.

Gotchas. CSP is the only one that takes real work: turn it on with Content-Security-Policy-Report-Only first, collect violations for a week, and expect inline scripts, analytics snippets, and embedded iframes to break, which is why nonces or hashes beat 'unsafe-inline'. HSTS is close to irreversible once browsers cache it, and the preload list is worse, so do not ship includeSubDomains until every subdomain really does have a certificate. And an A+ grade from a header scanner measures your headers, not your app: it says nothing about your authorization bugs.

Ask AI for it

Add security headers to every response from this app, set once in middleware or edge config rather than per route. Include Strict-Transport-Security with max-age=31536000 (add includeSubDomains only after confirming every subdomain has TLS), X-Content-Type-Options: nosniff, Referrer-Policy: strict-origin-when-cross-origin, a Permissions-Policy denying camera, microphone, and geolocation, and a Content-Security-Policy using per-request nonces for scripts, with no 'unsafe-inline', plus frame-ancestors 'none'. Ship the CSP as Content-Security-Policy-Report-Only first with a report endpoint, and list which of our third-party scripts will need allowlisting. Do not add X-XSS-Protection.

You might have meant

content security policycorsclickjackinghardeningdefense in depth

Go deeper