错误:内容安全策略:该页面的设置阻止加载资源 [英] Error: Content Security Policy: The page’s settings blocked the loading of a resource

查看:801
本文介绍了错误:内容安全策略:该页面的设置阻止加载资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在试图将我在jQuery / HTML中创建的简单程序转移到Firefox WebExtension中,以便于部署。我得到的错误是:

I've been trying to move a simple program I made in jQuery/HTML to a Firefox WebExtension for easy deployment. The error I am getting is:

Content Security Policy: The page’s settings blocked the loading of a resource at https://code.jquery.com/jquery-1.12.4.js ("script-src moz-extension://ef8f1295-1912-4912-ab2e-121053b6781a").

我确定我只是没有执行 manifest.json 文件的权利,但对我的生活,我不知道在哪里:
$ b

I'm sure I'm just not doing the manifest.json file right, but for the life of me I don't know where:

{
  "description": "Makes tasks from different underwriters uniform",
  "manifest_version": 2,
  "name": "Task Creator",
  "version": ".5",
  "permissions": [
    "http://*/*", "tabs", "https://*/*"
  ],

  "icons": {
    "48": "icons/page-48.png"
  },
  "web_accessible_resources": [
    "style/popUpStyle.css",
    "script/popUpTask.js",
    "script/logicTaskFiller.js",
    "js/autosize.js",
    "style/https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css",
    "js/https://code.jquery.com/jquery-1.12.4.js",
    "js/https://code.jquery.com/ui/1.12.1/jquery-ui.js"
  ],

  "background": {
    "scripts": ["background.js"]
  },

  "browser_action": {
    "default_icon": "icons/page-32.png"
  }
}


推荐答案

默认情况下,扩展名无法从Internet上加载脚本或其他对象资源。您的扩展使用的所有CSS和Javascript应该是扩展包的一部分。

By default, extensions cannot load scripts, or other object resources, from the Internet. All CSS and Javascript used by your extension should be part of the extension package.

(This文档来自Chrome,但完全相同的政策适用于Firefox WebExtensions。)

(This documentation is from Chrome, but the exact same policies apply to Firefox WebExtensions.)

可以放松这些限制,但通常应该避免这种限制 - 从如果用户无法访问Internet,或者他们位于限制性防火墙后面,则远程服务器将使您的分机无法正常工作。此外, addons.mozilla.org不会接受执行插件远程托管的Javascript

It's possible to relax these restrictions somewhat, but this should generally be avoided -- loading resources from a remote server will make your extension fail to work properly if the user does not have Internet access, or if they are behind a restrictive firewall. Additionally, addons.mozilla.org will not accept addons which execute remotely hosted Javascript.

这篇关于错误:内容安全策略:该页面的设置阻止加载资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆