Skip to content

chore: send security headers with every response - #8

Merged
simien merged 1 commit into
mainfrom
chore/security-headers
Sep 13, 2026
Merged

simien merged 1 commit into
mainfrom
chore/security-headers

Conversation

@simien

@simien simien commented Sep 13, 2026

Copy link
Copy Markdown
Owner

What does this change?

Adds a _headers file, which Cloudflare reads at deploy and applies to every response. flield.com currently sends no security headers. This adds:

  • X-Content-Type-Options: nosniff
  • Referrer-Policy: strict-origin-when-cross-origin
  • Permissions-Policy turning off camera, microphone, geolocation, payment, and USB
  • A Content-Security-Policy locked to the site's own origin, plus the two Cloudflare Web Analytics hosts the dashboard injects

The CSP keeps 'unsafe-inline' for scripts and styles because every page carries its script inline and there is no server to mint a nonce. It still blocks scripts from any other host, <base> hijacking, plugins, and forms posting anywhere else.

Not included on purpose: frame-ancestors or X-Frame-Options. Nothing says flield.com must never be embedded, so this leaves framing alone.

Related issue

None. Came out of the site-wide audit that landed as d062ac9 and 509a42f.

How was this tested?

Served the repo locally through a small Python server that applies the headers from _headers verbatim, then in Chrome: confirmed each header on the response, listened for securitypolicyviolation events (none), exported PNG and SVG, ran a GIF export so gif.js and its worker loaded, confirmed the favicon still redraws from a data: URL, toggled the theme, and loaded the flow-fields explainer with its six live canvases drawn.

The Workers Builds preview for this branch already serves the headers: curl -I on its / and /guide/ shows all four, and /_headers itself returns 404, so Cloudflare consumed the file rather than publishing it.

Checklist

  • No new build step, package manager, framework, or CDN dependency introduced
  • generator.js still has no dependency on the UI, if touched (not touched)
  • Tested locally in at least one browser

🤖 Generated with Claude Code

flield.com served no security headers at all. Cloudflare reads a
_headers file from the assets directory at deploy and applies it, so
this adds the four that fit a static site with no forms and no
third-party code: nosniff, a referrer policy, a permissions policy that
turns off the device APIs the app never asks for, and a content security
policy locked to the site's own origin.

The policy keeps 'unsafe-inline' for scripts and styles, since every
page carries its script inline and nothing exists to mint a nonce. It
still stops any script from another host, re-basing, plugins, and forms
posting elsewhere. Cloudflare Web Analytics is the one outside party the
dashboard injects, and both of its hosts are allowed.

Checked by serving the repo locally with these exact headers: no
violation events, PNG and SVG export, the GIF encoder and its worker,
the redrawn favicon, the theme toggle, and the explainers' live
canvases all ran as before.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
flield 54b6c2a Commit Preview URL

Branch Preview URL
Sep 13 2026, 08:55 PM

@simien
simien merged commit ae52008 into main Sep 13, 2026
2 checks passed
@simien
simien deleted the chore/security-headers branch September 13, 2026 21:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant