Draft
Add Cloudflare Worker to inject missing HTTP security headers#271
Conversation
The site is hosted on GitHub Pages behind Cloudflare. GitHub Pages cannot set custom HTTP response headers, so securityheaders.com gave the site an F. This adds a Cloudflare Worker (cloudflare/worker.js) that attaches the six missing security headers to every response: - Strict-Transport-Security (HSTS, 1-year + preload) - Content-Security-Policy (mirrors the existing HTML meta tag) - X-Frame-Options (SAMEORIGIN) - X-Content-Type-Options (nosniff) - Referrer-Policy (strict-origin-when-cross-origin) - Permissions-Policy (camera/mic/geo/payment/usb disabled) A GitHub Actions workflow (.github/workflows/deploy-worker.yml) deploys the worker automatically on every push to main that touches the cloudflare/ directory. Two repository secrets must be added to activate it: CLOUDFLARE_API_TOKEN — a token with "Edit Workers" permission CLOUDFLARE_ACCOUNT_ID — the Cloudflare account ID Also removes the expired Chrome Prompt API origin-trial meta tag (it expired 24 Mar 2026) from _layouts/default.html.
Copilot
AI
changed the title
feat: add Cloudflare Worker to inject missing HTTP security headers
Add Cloudflare Worker to inject missing HTTP security headers
Aug 2, 2026
Copilot created this pull request from a session on behalf of
lpmi-13
August 2, 2026 17:49
View session
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
securityheaders.com rates the site F — all six security headers absent. GitHub Pages can't set HTTP response headers; the existing CSP/Referrer-Policy
<meta>tags are browser-only and invisible to scanners.Since the site is already Cloudflare-proxied (172.67.219.232), a Worker is the right insertion point.
Changes
cloudflare/worker.js— Worker that passes requests to origin and sets all six headers on every response:Strict-Transport-Securitymax-age=31536000; includeSubDomains; preloadContent-Security-PolicyX-Frame-OptionsSAMEORIGINX-Content-Type-OptionsnosniffReferrer-Policystrict-origin-when-cross-originPermissions-Policycloudflare/wrangler.toml— routes worker overremotehack.space/*.github/workflows/deploy-worker.yml— deploys on push tomainwhencloudflare/**changes; requires two repo secrets:CLOUDFLARE_API_TOKEN(Edit Workers permission)CLOUDFLARE_ACCOUNT_ID_layouts/default.html— removes expired Chrome Prompt API origin-trial token (expired 24 Mar 2026)