Skip to content

Module 03 · Lesson 06

Security headers that matter

A few lines of config that close whole classes of attacks.

Fix8 min
HeaderWhy
Strict-Transport-SecurityForces HTTPS on return visits
Content-Security-PolicyLimits which scripts can run: the big defence against XSS
X-Content-Type-Options: nosniffStops browsers guessing file types
Referrer-PolicyControls what URL data leaks to other sites
Permissions-PolicyTurns off camera, mic, location if you don't use them
frame-ancestors (in CSP)Stops other sites framing yours (clickjacking)
/*
  Strict-Transport-Security: max-age=31536000; includeSubDomains
  X-Content-Type-Options: nosniff
  Referrer-Policy: strict-origin-when-cross-origin
  Permissions-Policy: camera=(), microphone=(), geolocation=()
  Content-Security-Policy: default-src 'self'; frame-ancestors 'none'
A `_headers` file for static hosts like Cloudflare Pages and Netlify. Start CSP strict, test every page, and loosen only what breaks.