Skip to content

Commit fdd449e

Browse files
committed
Stricter CSP in production
1 parent 45c6b47 commit fdd449e

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

next.config.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
const { locales, defaultLocale } = require("./data/locales.js")
22

3+
function notIfProduction(param) {
4+
if (process.env.NODE_ENV === "production") return ""
5+
else return param
6+
}
7+
38
/** @type {import('next').NextConfig} */
49
const nextConfig = {
510
reactStrictMode: true,
@@ -53,8 +58,7 @@ const nextConfig = {
5358
},
5459
{
5560
key: "Content-Security-Policy",
56-
value:
57-
"default-src 'self'; child-src 'none'; object-src 'none'; img-src 'self' proxy.joinmastodon.org blob: data:; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; connect-src 'self' api.joinmastodon.org; block-all-mixed-content",
61+
value: `default-src 'self'; child-src 'none'; object-src 'none'; img-src 'self' proxy.joinmastodon.org blob: data:; style-src 'self' 'unsafe-inline'; script-src 'self' ${notIfProduction("'unsafe-inline' 'unsafe-eval'")}; connect-src 'self' api.joinmastodon.org; block-all-mixed-content`,
5862
},
5963
],
6064
})

0 commit comments

Comments
 (0)