Angular ServiceWorkers + MIME type error

前端 未结 2 1319
忘掉有多难
忘掉有多难 2021-02-19 13:55

I\'m trying to add service workers to our existing angular (5.2, CLI 1.7.1) application. I did everything I was suppose to:

  1. I created ngsw-config.json
2条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-19 14:32

    This is probably caused by a missing ngsw-worker.js file.

    Likely you are using HTML5 pushState style URLs, and you have configured your web server to return your index page (typically index.html) for any file or folder that does not physically exist on the server. If ngsw-worker.js does not physically exist, the web server will redirect a request to ngsw-worker.js to index.html (hence the MIME type "text/html").

    The ngsw-worker.js file is typically copied to your dist folder when you run

    ng build --prod
    

提交回复
热议问题