为什么SimpleHTTP2Server无法在localhost上加载服务工作者

时间:2017-01-14 18:24:42

标签: polymer polymer-1.0 http2

当我尝试在本地运行Polymer Shop时,使用端口5000在本地主机上使用SimpleHTTP2Server进行捆绑和非捆绑构建时,对service-worker.js的请求失败:< / p>

An SSL certificate error occurred when fetching the script.
https://localhost:5000/service-worker.js Failed to load resource: net::ERR_INSECURE_RESPONSE
(index):1 Uncaught (in promise) DOMException: Failed to register a     ServiceWorker: An SSL certificate error occurred when fetching the script.

有一种简单的方法可以让它发挥作用吗?我尝试了许多启动标志,例如:

chrome.exe --ignore-certificate-errors --incognito
--unsafely-treat-insecure-origin-as-secure --allow-insecure-localhost

但这没有帮助,我仍然得到:

(index):1 Uncaught (in promise) DOMException: Failed to register a ServiceWorker: An SSL certificate error occurred when fetching the script.

1 个答案:

答案 0 :(得分:2)

根据alesc的建议,我找到了说明here

这些是Windows 10上Chrome 55的说明。似乎这些步骤可能会经常更改。

  1. 在包含不受信任证书的页面上(https://以红色划掉),点击锁定以打开弹出窗口。
  2. 点击顶部信息部分下的详细信息链接。
  3. 单击“查看证书”按钮。
  4. 单击“详细信息”选项卡
  5. 点击复制到文件
  6. 点击下一步
  7. 导出为PKCS#7
  8. 打开Chrome设置&gt;显示高级设置&gt; HTTPS / SSL&gt;管理证书
  9. 将步骤7中创建的证书导入“中级证书颁发机构”选项卡以及“受信任的权限”选项卡。
  10. 重新启动Chrome并打开您的localhost网站。