【问题标题】:Angular 7: ngsw-worker.js failed to loadAngular 7:ngsw-worker.js 加载失败
【发布时间】:2019-04-01 11:31:35
【问题描述】:

问题

有一个使用Service Worker通用应用。

最近从 Angular 6.1 升级到 7

将更新后的文件上传到服务器后得到:

详情:

The script has an unsupported MIME type ('text/html'). Failed to load resource: net::ERR_INSECURE_RESPONSE main.2733b77522d2feee4713.js:1 ERROR Error: Uncaught (in promise): SecurityError: Failed to register a ServiceWorker: The script has an unsupported MIME type ('text/html'). at j (polyfills.92108b287fe28032870b.js:1) at polyfills.92108b287fe28032870b.js:1 at polyfills.92108b287fe28032870b.js:1 at e.invoke (polyfills.92108b287fe28032870b.js:1) at Object.onInvoke (main.2733b77522d2feee4713.js:1) at e.invoke (polyfills.92108b287fe28032870b.js:1) at t.run (polyfills.92108b287fe28032870b.js:1) at polyfills.92108b287fe28032870b.js:1 at e.invokeTask (polyfills.92108b287fe28032870b.js:1) at Object.onInvokeTask (main.2733b77522d2feee4713.js:1) Sr @ main.2733b77522d2feee4713.js:1 t.handleError @ main.2733b77522d2feee4713.js:1 ... (anonymous) @ main.2733b77522d2feee4713.js:1 The script has an unsupported MIME type ('text/html'). Failed to load resource: net::ERR_INSECURE_RESPONSE The script has an unsupported MIME type ('text/html'). Failed to load resource: net::ERR_INSECURE_RESPONSE

SSL

使用https://letsencrypt.org/生成的有效证书。

Chrome 安全

【问题讨论】:

    标签: javascript angular service-worker angular7


    【解决方案1】:

    原因是某些包的某些版本不能一起玩。

    我的解决方案是ng new整个新项目,一步一步传输文件。之后一切正常(使用 Angular v7)。

    结论:在更新任何项目之前检查 3 次。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-08-18
      • 2020-04-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-12-15
      • 2020-03-13
      相关资源
      最近更新 更多