【问题标题】:Why does chromecast api fail to load in chrome extension?为什么chromecast api无法在chrome扩展中加载?
【发布时间】:2014-05-05 16:09:00
【问题描述】:

我正在尝试打开构建一个 chrome 扩展,作为 chromecast 应用程序的控制器。应用加载 Chromecast API 失败:

Failed to load resource: net::ERR_FAILED chrome-extension://www.gstatic.com/cast/sdk/libs/receiver/2.0.0/cast_receiver.js

在我的 index.html 标头中:

<script src="//www.gstatic.com/cast/sdk/libs/receiver/2.0.0/cast_receiver.js"></script>

我尝试在清单中添加 gstatic:

"permissions": [
        "www.gstatic.com/"
    ]

所以没有成功。将 API 包含到 chrome 扩展中我做错了什么?

【问题讨论】:

    标签: javascript google-chrome-extension chromecast


    【解决方案1】:

    Chrome 扩展在chrome-extension:// 而非https:// 架构上运行。由于您在 &lt;script/&gt; 中有一个与方案无关的 URL,Chrome 会尝试从扩展文件加载资源。使用&lt;script src="https://www.gstatic.com/.."&gt;&lt;/script&gt;

    您还必须更改您的权限以包含https://

    【讨论】:

    • 要加载脚本,需要将源域添加到 CSP,而不是 permissions 条目。
    猜你喜欢
    • 1970-01-01
    • 2014-08-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-28
    • 2012-11-06
    • 2021-01-14
    相关资源
    最近更新 更多