We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e87b739 commit 42c309aCopy full SHA for 42c309a
examples/with-strict-csp/pages/_document.js
@@ -6,12 +6,16 @@ const cspHashOf = (text) => {
6
hash.update(text)
7
return `'sha256-${hash.digest('base64')}'`
8
}
9
-
10
export default class MyDocument extends Document {
11
render() {
12
- const csp = `default-src 'self'; script-src 'self' ${cspHashOf(
+ let csp = `default-src 'self'; script-src 'self' ${cspHashOf(
13
NextScript.getInlineScriptSource(this.props)
14
)}`
+ if (process.env.NODE_ENV !== 'production') {
15
+ csp = `style-src 'self' 'unsafe-inline'; font-src 'self' data:; default-src 'self'; script-src 'unsafe-eval' 'self' ${cspHashOf(
16
+ NextScript.getInlineScriptSource(this.props)
17
+ )}`
18
+ }
19
20
return (
21
<html>
0 commit comments