Skip to content

Commit 174f716

Browse files
committed
feat: update Content Security Policy in Next.js configuration to allowlist third-party scripts and resources for production builds
1 parent c7430e8 commit 174f716

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

next.config.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,18 @@ const withBundleAnalyzer = bundleAnalyzer({
77

88
const isDev = process.env.NODE_ENV === "development";
99

10+
// CSP is only sent in production builds (see headers() below). Third-party
11+
// checkout widgets must be allowlisted explicitly — default-src 'self' blocks
12+
// their scripts/iframes/fetches when frame-src/connect-src are omitted.
13+
// Turnstile: https://developers.cloudflare.com/turnstile/reference/content-security-policy/
1014
const cspHeader = `
1115
default-src 'self';
12-
script-src 'self' 'unsafe-eval' 'unsafe-inline';
13-
style-src 'self' 'unsafe-inline';
16+
script-src 'self' 'unsafe-eval' 'unsafe-inline' https://challenges.cloudflare.com https://js.stripe.com https://va.vercel-scripts.com;
17+
style-src 'self' 'unsafe-inline' https://challenges.cloudflare.com;
1418
img-src 'self' blob: data: https:;
1519
font-src 'self' data:;
20+
connect-src 'self' https://challenges.cloudflare.com https://api.stripe.com https://vitals.vercel-insights.com;
21+
frame-src 'self' https://challenges.cloudflare.com https://js.stripe.com https://hooks.stripe.com;
1622
object-src 'none';
1723
base-uri 'self';
1824
form-action 'self';

0 commit comments

Comments
 (0)