Skip to content

fix(security): allow the cloudflare analytics beacon in the csp - #651

Merged
TheMeinerLP merged 2 commits into
mainfrom
fix/csp-cloudflare-insights
Nov 23, 2026
Merged

TheMeinerLP merged 2 commits into
mainfrom
fix/csp-cloudflare-insights

Conversation

@TheMeinerLP

Copy link
Copy Markdown
Collaborator

On production, Chrome logs a CSP issue for Cloudflare's Web Analytics beacon and Lighthouse Best Practices dropped to 79 (inspector-issues). Locally the beacon is not injected, so the earlier allowlist check missed it.

Cloudflare injects https://static.cloudflareinsights.com/beacon.min.js/... at the edge, and the report-only policy from 1.38.0 did not allow it.

The policy now allows https://static.cloudflareinsights.com in script-src and https://cloudflareinsights.com in connect-src (the beacon posts to /cdn-cgi/rum). The pinned source list in the spec was updated first.

Note: Cloudflare's FAQ lists the script as .../beacon.min.js and only 'self' for connect-src with automatic injection. The real script URL carries a path suffix, so a path-exact source would not match; origins are used instead.

Cloudflare injects its Web Analytics beacon at the edge. The report-only policy did not
allow it, so Chrome logged a CSP issue and Lighthouse Best Practices dropped.
With automatic injection the beacon reports to /cdn-cgi/rum on the
same host, so only script-src needs the Cloudflare origin.
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 23, 2026 •

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
launchpad 99306ee Commit Preview URL

Branch Preview URL
Nov 23 2026, 12:48 AM

@TheMeinerLP
TheMeinerLP merged commit 58d0f77 into main Nov 23, 2026
13 checks passed
@TheMeinerLP
TheMeinerLP deleted the fix/csp-cloudflare-insights branch November 23, 2026 00:51
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