SECURITY HEADERSQuick wins on any hostA header scanner has come back with a list of missing security headers, and someone now wants to know if the website is unsafe. Security headers are short instructions your server sends with each response, switching on protections the browser already has. Most take minutes to add. The one that needs care is Content-Security-Policy, because a rushed policy can break analytics, embeds and tag managers.
Which security headers matter?
Five are worth setting on almost every site, plus one older header that still has a job:
Strict-Transport-Security(HSTS): tells browsers to reach your domain over HTTPS only, upgrades anyhttp://request automatically and stops visitors clicking through certificate errors.Content-Security-Policy(CSP): lists where scripts, styles, images and frames may load from, which helps guard against cross-site scripting.X-Content-Type-Options: nosniff: makes the browser respect the declared file type instead of guessing it.Referrer-Policy: controls how much of the page address is passed to other sites in theRefererheader.Permissions-Policy: switches off browser features you don't use, such as camera, microphone and geolocation, for your pages and any iframes in them.X-Frame-Options: stops other sites showing your pages in a frame, a defence against clickjacking. CSP'sframe-ancestorsdirective is its more flexible replacement.
Which ones are safe to add today?
The quick wins are X-Content-Type-Options, Referrer-Policy and Permissions-Policy, each with one check before you switch it on.
- With
nosniff, the browser blocks a script or stylesheet whoseContent-Typedoesn't match, so confirm your server sendstext/cssfor CSS and a JavaScript type for scripts. strict-origin-when-cross-originsends the full address within your site, only the domain to other HTTPS sites and nothing to plain HTTP. It is already the browser default, but OWASP recommends setting it explicitly.camera=(), microphone=(), geolocation=()turns those features off for the page and its iframes, so leave out anything a map or video-call widget needs. Some widely used browsers don't support this header yet, so treat it as an extra layer.
How do we turn on HSTS without locking people out?
Start with a short max-age and raise it in stages. Once a browser has seen the header, it refuses plain HTTP for your domain and won't let visitors past a certificate error until max-age runs out. Browsers ignore the header sent over HTTP, so your HTTP-to-HTTPS redirect must already work.
The HSTS preload site suggests stages of five minutes (max-age=300), one week and one month, checking for broken pages and waiting the full max-age before each step up. includeSubDomains covers every subdomain, so first confirm each one works over HTTPS, including old landing pages on other platforms.
Preloading goes further: browsers ship your domain as HTTPS-only. It needs a max-age of at least one year, plus includeSubDomains and preload, and inclusion can't easily be undone. We treat it as a final step, not a quick win.
Why start Content-Security-Policy in report-only?
Because report-only shows everything a policy would block, without blocking it. Once a policy includes default-src or script-src, inline scripts stop running unless allowed, and anything from an unlisted domain is refused: analytics, tag managers, chat widgets, video embeds. Adding 'unsafe-inline' isn't the answer; MDN warns it defeats much of the purpose of a CSP.
Content-Security-Policy-Report-Only takes the same directives but only reports. Reports go to an endpoint named in Reporting-Endpoints and selected with report-to; MDN suggests also adding the older report-uri until report-to works everywhere. A cautious first set:
Strict-Transport-Security: max-age=300; includeSubDomains
X-Content-Type-Options: nosniff
Referrer-Policy: strict-origin-when-cross-origin
Permissions-Policy: camera=(), microphone=(), geolocation=()
X-Frame-Options: SAMEORIGIN
Reporting-Endpoints: csp-endpoint="https://www.example.com/csp-reports"
Content-Security-Policy-Report-Only: default-src 'self'; frame-ancestors 'self'; report-uri /csp-reports; report-to csp-endpointExpect plenty of reports at first: every third-party script, font and embed shows up, and that list becomes your allowlist. Allow or remove each one, then rename the header to Content-Security-Policy to enforce it. Until then, X-Frame-Options does the anti-framing work. Once an enforced policy includes frame-ancestors, supporting browsers ignore X-Frame-Options, which can stay for older ones.
Where do we set them, and how do we check?
Wherever your pages are served from: the web server, the host or the framework. Two common places:
- Apache:
Header always setlines in.htaccess, the file WordPress also uses for its permalink rules, if the host allows overrides.alwaysadds the header to redirects and error responses too. - Next.js: the
headers()function innext.config.js, with a source pattern such as/:path*to cover every route.
To check, rerun the header scanner or use developer tools: in Chrome's Network panel, select the page request, open Headers and read Response Headers. Test a normal page, a redirect and a missing page, since some servers only add headers to successful responses.
Where to start
Add the three quick wins and a five-minute HSTS header first, then run CSP in report-only and build the allowlist from real reports before enforcing it. For Next.js apps, our web app development work sets headers in code, so they are reviewed and tested like any other change. If the scan is part of a bigger question about an ageing site, start with a website review.
FAQ
Frequently asked questions
Should we add X-XSS-Protection as well?
No. MDN marks it deprecated and non-standard, and warns that in some cases it can create cross-site scripting holes in otherwise safe sites. OWASP's advice is not to set it, or to turn it off explicitly with X-XSS-Protection: 0, and to rely on a Content-Security-Policy that disallows inline JavaScript instead. A scanner flagging it as missing is nothing to worry about.
Can we add security headers with a meta tag instead?
Mostly not. The HSTS standard tells browsers to ignore it in a <meta> tag, and MDN says X-Frame-Options set there has no effect. A CSP can go in a <meta> element, but frame-ancestors, report-uri and sandbox are ignored and report-only mode isn't supported. Referrer policy is the exception: <meta name="referrer"> sets it for the whole page.
Can we set security headers on a Webflow site?
Partly. HSTS options sit in Site settings, Publishing, Advanced publishing options, with separate toggles for subdomains and the preload header. Other custom security headers have to be enabled per site by Webflow's sales team, and changes only apply after you republish. Webflow doesn't currently support Permissions-Policy and suggests Feature-Policy instead.
Will a Content-Security-Policy stop Google Tag Manager working?
It can, unless the policy allows it. Google's guidance says the CSP must permit the Tag Manager container code, ideally with a nonce, a random value generated for each response, and discourages 'unsafe-inline'. Custom JavaScript variables evaluate to undefined unless 'unsafe-eval' is allowed, and tags that call other domains need those domains listed. Tag Assistant shows which resources your CSP blocked.
How do we undo HSTS if something goes wrong?
Send the header again with max-age=0 over HTTPS. Browsers drop the rule on their next secure visit, but a visitor who doesn't come back keeps the old rule until it expires, which is why we start at five minutes. Preloaded domains are harder: the preload site says removal takes months to reach users through a Chrome update.

