Skip to content

Commit 79610c0

Browse files
committed
csp
1 parent 98f8282 commit 79610c0

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

next.config.mjs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,25 @@ const nextConfig = {
2121
},
2222
serverExternalPackages: [],
2323
async headers() {
24+
const isNonProduction = process.env.NODE_ENV !== "production"
25+
const scriptSrc = ["'self'", "'unsafe-inline'"]
26+
const connectSrc = ["'self'", "https://api.github.com", "https://github.com"]
27+
28+
if (isNonProduction) {
29+
scriptSrc.push("https://vercel.live", "https://*.vercel.live")
30+
connectSrc.push("https://vercel.live", "https://*.vercel.live")
31+
}
32+
2433
const csp = [
2534
"default-src 'self'",
2635
"base-uri 'self'",
2736
"frame-ancestors 'none'",
2837
"object-src 'none'",
29-
"script-src 'self' 'unsafe-inline'",
38+
`script-src ${scriptSrc.join(" ")}`,
3039
"style-src 'self' 'unsafe-inline'",
3140
"img-src 'self' data: https:",
3241
"font-src 'self' data:",
33-
"connect-src 'self' https://api.github.com https://github.com",
42+
`connect-src ${connectSrc.join(" ")}`,
3443
"form-action 'self' https://github.com",
3544
].join("; ")
3645

0 commit comments

Comments
 (0)