Skip to content

Commit 0d64124

Browse files
authored
Merge pull request #30 from JonDevOps/claude/csp-report-only
Content Security Policy, report-only (#467)
2 parents ba1dc80 + 97e2232 commit 0d64124

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

‎next.config.js‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,23 @@
11

2+
// Where the site loads things from: Firebase (Auth, Firestore, Storage,
3+
// Functions), App Check's reCAPTCHA, Google Analytics, and the Discord and
4+
// YouTube embeds. Images can come from any https address, since profile
5+
// pictures are links members add.
6+
const CONTENT_SECURITY_POLICY = [
7+
"default-src 'self'",
8+
"script-src 'self' 'unsafe-inline' https://www.google.com https://www.gstatic.com https://apis.google.com https://www.googletagmanager.com",
9+
"style-src 'self' 'unsafe-inline' https://fonts.googleapis.com",
10+
"font-src 'self' data: https://fonts.gstatic.com",
11+
"img-src 'self' data: blob: https:",
12+
"connect-src 'self' https://*.googleapis.com https://*.firebaseio.com wss://*.firebaseio.com https://*.cloudfunctions.net https://*.run.app https://www.google-analytics.com https://*.google-analytics.com https://www.googletagmanager.com https://www.google.com",
13+
"frame-src 'self' https://*.firebaseapp.com https://www.google.com https://recaptcha.google.com https://discord.com https://www.youtube.com https://www.youtube-nocookie.com",
14+
"media-src 'self' https:",
15+
"object-src 'none'",
16+
"base-uri 'self'",
17+
"form-action 'self'",
18+
"frame-ancestors 'self'",
19+
].join('; ');
20+
221
/** @type {import('next').NextConfig} */
322
const nextConfig = {
423
images: {
@@ -30,6 +49,10 @@ const nextConfig = {
3049
{ key: 'X-Content-Type-Options', value: 'nosniff' },
3150
{ key: 'Referrer-Policy', value: 'strict-origin-when-cross-origin' },
3251
{ key: 'Permissions-Policy', value: 'camera=(self), microphone=(self), geolocation=(), payment=(), usb=()' },
52+
// Report-only for now: browsers log anything this would block in the
53+
// console, without blocking it. Once it's quiet, rename the key to
54+
// Content-Security-Policy to enforce it.
55+
{ key: 'Content-Security-Policy-Report-Only', value: CONTENT_SECURITY_POLICY },
3356
],
3457
}];
3558
},

0 commit comments

Comments
 (0)