Which security headers matter most
These six headers cover the most common browser-side attacks:
- Strict-Transport-Security (HSTS): forces HTTPS so attackers can't downgrade connections.
- Content-Security-Policy (CSP): limits where scripts can load from, which contains cross-site scripting.
- X-Frame-Options or CSP frame-ancestors: stops other sites from framing your pages (clickjacking).
- X-Content-Type-Options: nosniff stops browsers from guessing file types.
- Referrer-Policy: controls how much of your URLs leak to other sites.
- Permissions-Policy: turns off browser features you don't use, such as the camera and microphone.
A safe starting set
Most startups can add these without breaking anything, then roll out CSP in report-only mode first:
Strict-Transport-Security: max-age=31536000; includeSubDomains
X-Frame-Options: DENY
X-Content-Type-Options: nosniff
Referrer-Policy: strict-origin-when-cross-origin
Permissions-Policy: camera=(), microphone=(), geolocation=()Where to add them
On Vercel, set them in vercel.json or vercel.ts headers, or in next.config headers(). On Cloudflare, use a Transform Rule. On nginx, use add_header. Always test in staging first, especially CSP, which can block your own scripts if it's too strict.
Frequently asked questions
Do security headers affect SEO?
Not directly, but HTTPS is a ranking signal and HSTS makes sure every visit uses HTTPS. Security headers mainly protect your users and show up in enterprise security reviews.
Why is my Content-Security-Policy breaking my site?
CSP blocks any script, style or connection not on its allowlist. Start with Content-Security-Policy-Report-Only to collect violations without blocking, add the sources you actually use, then switch to enforcing mode.
Is X-Frame-Options still needed if I have CSP?
CSP frame-ancestors replaces X-Frame-Options in modern browsers. Sending both is harmless and covers older browsers.
More free security tools
SSL Checker
Check any website's SSL/TLS certificate: validity, expiry date, issuer, covered hostnames (SANs), TLS version and cipher. Catch expiring or misconfigured certificates before users do.
OpenDMARC Checker
Check your domain's DMARC record instantly. See your policy (none, quarantine, reject), reporting addresses and exactly what to fix so attackers can't spoof your email.
OpenSubdomain Finder
Find a domain's subdomains from public Certificate Transparency logs. Spot exposed staging, admin and internal hosts before attackers do, without sending any traffic to the target.
Open