Skip to content

Commit cd6dacb

Browse files
committed
fix(web): allow Cloudflare RUM reporting
1 parent 1d245dd commit cd6dacb

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

‎apps/web/app/lib/security-headers.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,11 @@ export function buildContentSecurityPolicy(
6161
env: RuntimeEnv = process.env,
6262
): string {
6363
const apiOrigin = origin(env.CNODE_API_BASE_URL || "https://api.cnodejs.org");
64-
const connectSources = ["'self'", "https://challenges.cloudflare.com"];
64+
const connectSources = [
65+
"'self'",
66+
"https://challenges.cloudflare.com",
67+
"https://cloudflareinsights.com",
68+
];
6569
if (apiOrigin && !connectSources.includes(apiOrigin)) connectSources.push(apiOrigin);
6670

6771
// Arbitrary HTTPS images are existing user-content behavior; scripts remain nonce-restricted.

‎apps/web/tests/SecurityHeaders.test.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,9 @@ describe("Web document security headers", () => {
9696
const policy = buildContentSecurityPolicy("nonce", {
9797
CNODE_API_BASE_URL: "https://api.example.com/v1",
9898
});
99-
expect(policy).toContain("connect-src 'self' https://challenges.cloudflare.com https://api.example.com");
99+
expect(policy).toContain(
100+
"connect-src 'self' https://challenges.cloudflare.com https://cloudflareinsights.com https://api.example.com",
101+
);
100102
expect(policy).toContain("frame-src https://challenges.cloudflare.com");
101103
expect(policy).toContain("img-src 'self' data: blob: https:");
102104
expect(policy).toContain("report-uri /__csp-report");

0 commit comments

Comments
 (0)