From 14094d1ad06f6596e1c0f6e9d0f974c351b1b655 Mon Sep 17 00:00:00 2001 From: Abhinav Date: Thu, 2 Dec 2021 13:18:44 +0530 Subject: [PATCH] added unsafe inline as fallback to hash for script-src --- src/pages/_document.tsx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/pages/_document.tsx b/src/pages/_document.tsx index cdee4b0d7..c8e71b68f 100644 --- a/src/pages/_document.tsx +++ b/src/pages/_document.tsx @@ -61,19 +61,19 @@ export default class MyDocument extends Document { } render() { - let csp = { - ...BASE_CSP_DIRECTIVES, - 'script-src': `'self' ${cspHashOf( + const scriptDirective = { + 'script-src': `'unsafe-inline' 'self' ${cspHashOf( NextScript.getInlineScriptSource(this.props) )}`, }; + let csp = { + ...BASE_CSP_DIRECTIVES, + ...scriptDirective, + }; if (process.env.NODE_ENV !== 'production') { csp = { - ...BASE_CSP_DIRECTIVES, + ...csp, ...DEV_CSP_DIRECTIVES, - 'script-src': `'unsafe-eval' 'self' ${cspHashOf( - NextScript.getInlineScriptSource(this.props) - )}`, }; } return (