[英]Problem chrome content security policy react extension manifest
I created a very simple extension chrome but I have a problem I can not fix it, the problem is of Content Security Policy of google chrome please I need help for fix it and this is the error:我创建了一个非常简单的扩展 chrome 但我有一个问题我无法修复它,问题是 google chrome 的内容安全策略,请我需要帮助来修复它,这是错误:
Refused to execute inline script because it violates the following Content Security Policy directive: "script-src 'self' blob: filesystem: chrome-extension-resource:".拒绝执行内联脚本,因为它违反了以下内容安全策略指令:“script-src 'self' blob: filesystem: chrome-extension-resource:”。 Either the 'unsafe-inline' keyword, a hash ('sha256-wkEhk1Pm58HZQSzT/oPAcIeUYSsJpEEGo2v2M1aGgTs='), or a nonce ('nonce-...') is required to enable inline execution.
启用内联执行需要“unsafe-inline”关键字、hash(“sha256-wkEhk1Pm58HZQSzT/oPAcIeUYSsJpEEGo2v2M1aGgTs=”)或随机数(“nonce-...”)。
React by default uses inline scripts which your browser will reject in an extension. React 默认使用你的浏览器将在扩展中拒绝的内联脚本。 Create a.env.production file in your react app and specify
INLINE_RUNTIME_CHUNK=false
inside of it.在您的 react 应用程序中创建一个 .env.production 文件并在其中指定
INLINE_RUNTIME_CHUNK=false
。
Source: https://gist.github.com/amad-person/f0ef85a2123a2e1fcf8052dcf09eef90资料来源: https://gist.github.com/amad-person/f0ef85a2123a2e1fcf8052dcf09eef90
You can also do this by updating the build script in package.json file您也可以通过更新 package.json 文件中的构建脚本来执行此操作
"build": "INLINE_RUNTIME_CHUNK=false react-scripts build"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.