Angular 7 PWA - 清单获取失败(状态:404)在 Driver

Angular 7 PWA - Manifest fetch failed (status: 404) at Driver

未捕获(承诺)错误:清单获取失败! (状态:404)在 Driver。 (ngsw-worker.js:2368) at Generator.next () at fulfilled (ngsw-worker.js:1780)

部署我的 angular 7 项目 (PWA) 后出现此错误。有什么解决办法吗?

在你的 angular.json

"serviceWorker: true"  

并更新

npm install @angular-devkit/build-angular@latest

确保您的 ngsw-config.json 配置正确 和 在您的 angular.json 文件中,找到并更改为 serviceworker: true.

同样在您的 angular.json 中,检查是否 "src/manifest.json",列在“资产”数组中。

通过以下方式验证:https://yourdomain.com/manifest.json 可访问。

web.config 中添加以下行解决了问题。

<staticContent>
    <mimeMap fileExtension=".json" mimeType="application/json" />
 </staticContent>

我遇到了同样的问题,我找到了解决方案 here

If you upload a .json file to your Windows Azure website and try to access it, it would give you a 404 File Not Found error because the MIME Type of .json is not set by default. This also applies in general to any file that might need a specific MIME Type.

To fix this issue, FTP into your website and upload the following Web.config file which will set the correct MIME types. If you already have a Web.config file in place, just add the below to the appropriate section.

Web.config:

<?xml version="1.0"?>

<configuration>
   <system.webServer>
      <staticContent>
         <mimeMap fileExtension=".json" mimeType="application/json" />
      </staticContent>
   </system.webServer>
</configuration> 

我遇到了类似的问题...

Failed to load manifest.webmanifest . A ServiceWorker passed a promise to FetchEvent.respondWith() that resolved with non-Response value ‘undefined’.

我的清单名称是 manifest.webmanifest 并且我已经向我的服务工作者添加了一些过滤器以仅提供静态文件。
由于 .webmanifest 扩展,它无法识别为静态内容,并且当客户端离线时无法从缓存中提供服务。

我通过简单地将其重命名为 manifest.json.

解决了这个问题

希望这可以防止有人头疼...:)

我已经通过这个简单的步骤解决了我的问题:

转到根文件夹中的 angular.json

如果您的 manifest.json 在 src 文件夹中,请在资产中添加 src/manifest.json。否则请添加路径。

"assets": [
              "src/favicon.ico",
              "src/assets",
              "src/manifest.json"
          ],

重新启动开发服务器使用 ng serveng serve -o 打开项目