diff --git a/scripts/build.mjs b/scripts/build.mjs index f4cefc6..0e186a3 100644 --- a/scripts/build.mjs +++ b/scripts/build.mjs @@ -107,6 +107,10 @@ const write = (rel, html) => { console.log(`dist/${rel} ${(html.length / 1024).toFixed(0)} KB`); }; +// Cloudflare Web Analytics (no cookie): the beacon on every page but the 404; its host is allowed in the CSP below. +// The token is public by design, it ends up in the HTML. +const BEACON = ``; + fs.rmSync(DIST, {recursive: true, force: true}); fs.mkdirSync(DIST, {recursive: true}); @@ -120,6 +124,7 @@ for (const m of machines) {
+${BEACON} `; @@ -169,6 +174,7 @@ ${cards} +${BEACON} `; @@ -183,11 +189,11 @@ fs.writeFileSync( ); const csp = [ "default-src 'self'", - `script-src 'self' ${[...hashes].map((h) => `'sha256-${h}'`).join(' ')}`, + `script-src 'self' https://static.cloudflareinsights.com ${[...hashes].map((h) => `'sha256-${h}'`).join(' ')}`, "style-src 'self' 'unsafe-inline'", "img-src 'self' data: blob:", "font-src 'self' data:", - "connect-src 'self'", + "connect-src 'self' https://cloudflareinsights.com", "object-src 'none'", "base-uri 'self'", "form-action 'self'",