Angular 7: ngsw-worker.js failed to load

Viewed 1400

Problem

There is a universal app that uses a Service Worker.

Recently upgraded from Angular 6.1 to 7.

After uploading the updated files to the server getting:

enter image description here

Details:

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

Using a valid certificate generated by https://letsencrypt.org/.

Chrome Security

enter image description here

1 Answers

The reason was some versions of some packages that don't play together.

My solution was to ng new the whole new project and transfer files step by step. After that everything worked as it should (with Angular v7 in place).

Conclusion: check 3 times before update any proj.

Related