Google chrome Chrome扩展内容安全策略不允许使用资源
加载本地chrome扩展时,我收到以下错误:Google chrome Chrome扩展内容安全策略不允许使用资源,google-chrome,google-chrome-extension,Google Chrome,Google Chrome Extension,加载本地chrome扩展时,我收到以下错误: Refused to load the script 'https://widget.intercom.io/widget/APPID' because it violates the following Content Security Policy directive: "script-src 'self' http://localhost https://widget.intercome.io/ 'unsafe-eval'". index.h
Refused to load the script 'https://widget.intercom.io/widget/APPID' because it violates the following Content Security Policy directive: "script-src 'self' http://localhost https://widget.intercome.io/ 'unsafe-eval'".
index.html:1 XMLHttpRequest cannot load http://localhost:5000/login. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'chrome-extension://bbmhkchajfbhfjkfiaadlnohbfhbnegj' is therefore not allowed access.
我试图在我的manifest.json
中放入以下行:
"content_security_policy": "script-src 'self' http://localhost https://widget.intercome.io/ 'unsafe-eval'; object-src 'self'"
最后一行不应该特别允许我访问这两个资源吗?您对
https://widget.intercome.io
CSP规则,但您可能需要
intercom.io
,但您的CSP显示intercom.io
)localhost
错误是由执行同源策略而不是CSP引起的。(受connectsrc
CSP指令控制的Ajax请求不受Chrome扩展的默认CSP限制。)您需要添加http://localhost/*
作为一个:
您对
https://widget.intercome.io
CSP规则,但您可能需要
intercom.io
,但您的CSP显示intercom.io
)localhost
错误是由执行同源策略而不是CSP引起的。(受connectsrc
CSP指令控制的Ajax请求不受Chrome扩展的默认CSP限制。)您需要添加http://localhost/*
作为一个:
为了进一步扩展,对于将来来到这里的任何人:
这是正确的,但请确保将其包含在单独的文件中。我遇到了一个内联问题,所以我刚刚创建了一个名为intercom.js
的文件,然后将脚本包含在那里,并将其包含在我的HTML中
这也是我的工作原理:
"content_security_policy": "script-src 'self' http://localhost https://widget.intercom.io https://js.intercomcdn.com 'unsafe-eval'; object-src 'self'"
为了进一步扩展,对于将来来到这里的任何人:
这是正确的,但请确保将其包含在单独的文件中。我遇到了一个内联问题,所以我刚刚创建了一个名为intercom.js
的文件,然后将脚本包含在那里,并将其包含在我的HTML中
这也是我的工作原理:
"content_security_policy": "script-src 'self' http://localhost https://widget.intercom.io https://js.intercomcdn.com 'unsafe-eval'; object-src 'self'"
可能这是相关的:可能这是相关的: