script-src, unsafe-eval in CSP and editors
-
Hi WordPress team,
I am using wordpress 6.2.2 with gutenberg editor. I introduced CSP in .htaccess file and from then when I click on “Add New” in “Page” tab it is generating errors with white blank screen. The CSP and Error are below…
CSP :
Content-Security-Policy “default-src ‘self’ https: ‘unsafe-inline’; object-src ‘none’; img-src ‘self’ https: data: blob: *.gravatar.com; style-src ‘self’ ‘unsafe-inline’; worker-src ‘self’ blob:; font-src ‘self’ https: data: blob:; child-src ‘self’ https: data: blob:; frame-src ‘self’ https: data: blob:; script-src ‘self’ ‘unsafe-inline’; frame-ancestors ‘self’; form-action ‘self’ https: ‘unsafe-inline'”
Error :
Uncaught EvalError: Refused to evaluate a string as JavaScript because ‘unsafe-eval’ is not an allowed source of script in the following Content Security Policy directive: “script-src ‘self’ ‘unsafe-inline'”.
at ./node_modules/react-refresh/runtime.js (react-refresh-runtime.js:29:1)
at __webpack_require__ (react-refresh-runtime.js:53:41)
at react-refresh-runtime.js:64:37
at react-refresh-runtime.js:67:12Uncaught EvalError: Refused to evaluate a string as JavaScript because ‘unsafe-eval’ is not an allowed source of script in the following Content Security Policy directive: “script-src ‘self’ ‘unsafe-inline'”. data.js:345
at new Function ()
at data.js:345:30
at combineReducers (data.js:347:5)
at blocks.js:8559:97
at blocks.js:15470:2
at blocks.js:15472:12When I add “unsafe-eval” to script-src in CSP, no error will be generated and works fine.
But I need it to work without adding “unsafe-eval” to script-src in CSP. So please suggest me some alternate approach.
Thanks
- The topic ‘script-src, unsafe-eval in CSP and editors’ is closed to new replies.