简体   繁体   English

使用'script-src'允许网站不会影响错误

[英]Using 'script-src' to allow websites isn't affecting error

I'm making a browser extension but the Content Security Policy seems to be blocking some of my content. 我正在扩展浏览器,但是内容安全策略似乎阻止了我的某些内容。 I've added a meta tag to allow for a website: 我添加了一个meta标记以允许一个网站:

 <meta http-equiv="Content-Security-Policy" content="script-src https://cdnjs.cloudflare.com https://cdn.jsdelivr.net"> 

I'm still getting the same error message saying that the script-src is being blocked. 我仍然收到相同的错误消息,说script-src被阻止了。

警告带有源的脚本加载失败...

内容安全策略设置阻止资源加载的错误

How do I allow my resource to load? 如何允许我的资源加载?

ps I'm targeting Firefox and Google Chrome. ps我的目标是Firefox和Google Chrome。

Nevermind, I needed to put the code in my manifest.json file, instead of in the <head> of my html file. 没关系,我需要将代码放在我的manifest.json文件中,而不是放在html文件的<head>中。 It should look something like this: 它看起来应该像这样:

}
"content_security_policy": "script-src 'self' 'unsafe-eval' https://cdnjs.cloudflare.com https://cdn.jsdelivr.net; object-src 'self'",
}

I was able to find an answer in another post to help me with this. 我能够在另一篇文章中找到答案,以帮助我解决这个问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 内容安全策略指令:“script-src &#39;none&#39; 违规错误 - Content Security Policy directive: "script-src 'none' Violation Error 在普通 html 文件中对 script-src 和 style-src 使用 CSP 元标记 - Using CSP meta tag for script-src and style-src in normal html file 为什么<script src=“”> isn't working? - Why <script src=“”> isn't working? 为什么在 Chrome/Edge 中允许 CSP script-src 指令,而在 Firefox 中不允许? - Why is the CSP script-src directive allowed in Chrome/Edge, but not in Firefox? 获取错误主机定义的策略:内联脚本中违反了指令&#39;script-src ms-appx:&#39;unsafe-eval&#39;的资源。 资源将被阻止 - Getting error Resource violated directive 'script-src ms-appx: 'unsafe-eval'' in Host Defined Policy: inline script. Resource will be blocked 使用 Content-Security-Policy 和 JavaScript 避免 `script-src 'unsafe-inline'` - Avoiding `script-src 'unsafe-inline'` with Content-Security-Policy and JavaScript 内容安全策略:页面的设置阻止了内联资源的加载(“script-src”) - Content Security Policy: The page’s settings blocked the loading of a resource at inline (“script-src”) 影响 arrays 的值在 JavaScript 中不起作用? - affecting values into arrays isn't working in JavaScript? 内容安全策略指令:“script-src&#39;self&#39;blob:filesystem:chrome-extension-resource:”在获取是否 - Content Security Policy directive: “script-src 'self' blob: filesystem: chrome-extension-resource:” While fetching whether 网站的移动视图未调整大小 - websites mobile view isn't resizing
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM