fix: allow Next hydration scripts under CSP
This commit is contained in:
+6
-6
@@ -25,15 +25,15 @@ const baseSecurityHeaders = [
|
|||||||
// so a content policy doesn't apply to them anyway. connect-src stays broad
|
// so a content policy doesn't apply to them anyway. connect-src stays broad
|
||||||
// because the WebRTC call pages connect to the separately hosted LiveKit SFU
|
// because the WebRTC call pages connect to the separately hosted LiveKit SFU
|
||||||
// at runtime. style-src needs
|
// at runtime. style-src needs
|
||||||
// 'unsafe-inline' because framer-motion drives its animations through
|
// 'unsafe-inline' because Next App Router emits inline RSC flight/bootstrap
|
||||||
// inline style attributes. script-src allows 'unsafe-eval' only in dev,
|
// scripts that are required for hydration. script-src allows 'unsafe-eval'
|
||||||
// matching Next's own documented CSP guidance — React uses eval there for
|
// only in dev, matching Next's own documented CSP guidance — React uses eval
|
||||||
// server-error-stack reconstruction; neither React nor Next use it in a
|
// there for server-error-stack reconstruction; neither React nor Next use it
|
||||||
// production build.
|
// in a production build.
|
||||||
const isDev = process.env.NODE_ENV === "development";
|
const isDev = process.env.NODE_ENV === "development";
|
||||||
const frontendCSP = [
|
const frontendCSP = [
|
||||||
"default-src 'self'",
|
"default-src 'self'",
|
||||||
`script-src 'self'${isDev ? " 'unsafe-eval'" : ""}`,
|
`script-src 'self' 'unsafe-inline'${isDev ? " 'unsafe-eval'" : ""}`,
|
||||||
"style-src 'self' 'unsafe-inline'",
|
"style-src 'self' 'unsafe-inline'",
|
||||||
"img-src 'self' data: blob:",
|
"img-src 'self' data: blob:",
|
||||||
"font-src 'self' data:",
|
"font-src 'self' data:",
|
||||||
|
|||||||
Reference in New Issue
Block a user