Skip to content

fix: add a CSP nonce so Cloudflare's bot detection script can run - #13

Merged
fabianzimber merged 1 commit into
mainfrom
fix/csp-nonce-for-cloudflare-scripts
Nov 27, 2026
Merged

fabianzimber merged 1 commit into
mainfrom
fix/csp-nonce-for-cloudflare-scripts

Conversation

@fabianzimber

@fabianzimber fabianzimber commented Nov 27, 2026 •

Copy link
Copy Markdown
Member

What

Every HTML response now carries a fresh random nonce in script-src.

Why

Cloudflare's bot detection (JavaScript Detections, and challenge pre-clearance) injects a small inline script that loads /cdn-cgi/challenge-platform/.... leaf's CSP allows no inline scripts, so the browser blocked it. Cloudflare reads the nonce from the CSP response header and adds it to the script it injects. leaf's own markup does not use the nonce: all of leaf's scripts stay files on 'self', and 'unsafe-inline' is still not allowed.

How to test

  • npm run check
  • After deploy: open https://leaf.shiftbloom.studio/ with DevTools open. The console should show no CSP error for challenge-platform, and the content-security-policy header should contain a different 'nonce-…' on each reload.

@sonarqubecloud

Copy link
Copy Markdown

@fabianzimber
fabianzimber merged commit 4f1dd03 into main Nov 27, 2026
7 checks passed
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