【问题标题】:Ionic 4 and Firebase page not found找不到 Ionic 4 和 Firebase 页面
【发布时间】:2019-03-03 10:23:46
【问题描述】:

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

感谢大家的关注。

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

【问题讨论】:

    标签: firebase service-worker firebase-hosting ionic4


    【解决方案1】:

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

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

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

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

    希望对你有帮助

    【讨论】:

    • 感谢您的回答! :D
    猜你喜欢
    • 1970-01-01
    • 2018-09-04
    • 2017-09-21
    • 2020-06-09
    • 1970-01-01
    • 1970-01-01
    • 2019-05-31
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多