gg
HomeWeb & Hosting › Security Headers (_headers)
Web & Hosting

Security Headers (_headers)

Generate a hardened _headers file for Cloudflare Pages or Netlify: a strict Content-Security-Policy, HSTS, anti-clickjacking, no-sniff, a tight Referrer-Policy and Permissions-Policy. Drop it in your site root and your pages ship the same security headers this site does.

Try it now

💡 Good to know: One missing header can enable "clickjacking" — an attacker invisibly frames your site and steals the clicks meant for it.

Worked example

# _headers — Cloudflare Pages / Netlify. Put this file in your published site root. /* Content-Security-Policy: default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; font-src 'self'; connect-src 'self'; object-src 'none'; base-uri 'self'; frame-ancestors 'none'; form-action 'self' Strict-Transport-Security: max-age=31536000; includeSubDomains; preload X-Frame-Options: DENY X-Content-Type-Options: nosniff Referrer-Policy: strict-origin-when-cross-origin Permissions-Policy: geolocation=(), camera=(), microphone=() Cross-Origin-Opener-Policy: same-origin Cross-Origin-Resource-Policy: same-origin

Learn the method

Inputs

Frequently asked

Where does the _headers file go?

In your published site's root (for Cloudflare Pages) — it's applied automatically at the edge.

My styles broke — why?

A strict CSP blocks inline styles. Keep "Allow inline styles" on if your site uses style attributes, or move styles into a stylesheet and turn it off for maximum strictness.

Related Web & Hosting tools