首页 > 解决方案 > 找不到 Ionic 4 和 Firebase 页面

问题描述

我最近启动了一个 Ionic 4 项目,并使用命令添加了 service woker 并将其$ ng add @angular/pwa --project app托管在 firebase 上。它工作得既漂亮又完美,但是当我Ctrl + F5在页面上给出一个或用它进行审核时Lighthouse,我返回找不到页面并且只能再次工作,如果我去 url 并删除/home,只留下 url 基础,所以他可以安装服务人员并正常工作,如果我不执行上述程序:D。如果我能得到答案,我将不胜感激。

我感谢关注。

注意:对不起我的英语,我是巴西人,我不流利。

标签: firebaseservice-workerfirebase-hostingionic4

解决方案


我在使用 Ionic 4 时遇到了完全相同的问题@angular/pwa
解决方案是将以下重写添加到文件中firebase.json

"rewrites": [{
        "source": "**",
        "destination": "/index.html"
}]

所以firebase.json看起来像这样:

{
  "hosting": {
    "public": "www",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ],
    "rewrites": [{
        "source": "**",
        "destination": "/index.html"
    }]
  }
}

我希望这有帮助


推荐阅读