fix(csp): allow Cloudflare Web Analytics beacon#8
Merged
Conversation
The strict CSP (script-src 'self', connect-src 'self') blocked the beacon that Cloudflare Pages auto-injects, so Web Analytics recorded nothing. Allowlist the two beacon origins: - script-src: https://static.cloudflareinsights.com (beacon.min.js) - connect-src: https://cloudflareinsights.com (RUM /cdn-cgi/rum endpoint) Comment updated to reflect the one permitted third-party dependency. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Deploying caveviewer with
|
| Latest commit: |
1e04258
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://eb1de666.caveviewer.pages.dev |
| Branch Preview URL: | https://worktree-fix-csp-cf-analytic.caveviewer.pages.dev |
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.
Problem
Cloudflare Web Analytics was recording zero data. The cause is self-inflicted: the strict CSP in
index.htmlblocked the analytics beacon that Cloudflare Pages auto-injects into every served page.The served HTML contains:
…but the meta CSP blocked it on two fronts:
script-src 'self'→beacon.min.jsnever loadsconnect-src 'self'→ even if loaded, it couldn't POST RUM dataResult: two CSP violations in the console and no metrics.
Fix
Allowlist exactly the two origins the beacon uses, nothing broader:
script-src: addhttps://static.cloudflareinsights.comconnect-src: addhttps://cloudflareinsights.comAlso updated the adjacent comment, which previously claimed "No third-party/network resources" — no longer accurate now that the beacon is permitted.
Test plan
npm run buildsucceeds; CSP propagates intact todist/index.html🤖 Generated with Claude Code