Skip to content

Allow Cloudflare Web Analytics through CSP - #116

Merged
ashryanbeats merged 1 commit into
mainfrom
dev/allow-cloudflare-web-analytics
Jul 10, 2026
Merged

ashryanbeats merged 1 commit into
mainfrom
dev/allow-cloudflare-web-analytics

Conversation

@ashryanbeats

Copy link
Copy Markdown
Member

What changed

  • allow Cloudflare Web Analytics to load static.cloudflareinsights.com under the generated script-src policy
  • add regression coverage for the Cloudflare Insights origin

Why

Cloudflare automatically injects its Web Analytics beacon after the Astro build. The generated CSP allowed Google Tag Manager but not Cloudflare Insights, so browsers blocked beacon.min.js on page load.

This keeps the strict hash-based CSP intact without adding unsafe-inline. Cloudflare's separate JavaScript Detections inline-script warning remains a dashboard configuration concern and is intentionally outside this PR.

Validation

  • npx vitest run test/security-headers.test.mjs
  • npm run build
  • verified generated dist/_headers includes https://static.cloudflareinsights.com
  • git diff --check

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying kyoto-tech-github-io with  Cloudflare Pages  Cloudflare Pages

Latest commit: ba8c74b
Status: ✅  Deploy successful!
Preview URL: https://9a9edae2.kyoto-tech-github-io.pages.dev
Branch Preview URL: https://dev-allow-cloudflare-web-ana.kyoto-tech-github-io.pages.dev

View logs

@ashryanbeats
ashryanbeats marked this pull request as ready for review July 10, 2026 22:22
@ashryanbeats
ashryanbeats merged commit f120c59 into main Jul 10, 2026
2 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