我最近启动了一个 Ionic 4 项目,并使用 $ ng add @angular/pwa --project app
命令添加了服务woker,并将其托管在 firebase 上。它工作得很漂亮而且完美,但是当我在页面上输入 Ctrl + F5
或使用 Lighthouse
进行审核时,它会返回找不到页面,并且只有在我再次工作时才可以工作转到 url 并删除 /home
,仅保留 url 库,这样他就可以安装 Service Worker 并正常工作,以防万一我不执行上述过程:D。如果我能得到答案,我将不胜感激。
感谢您的关注。
注意:抱歉我的英语不好,我是巴西人,而且不太流利。
最佳答案
我在使用 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"
}]
}
}
希望这有帮助
关于firebase - 找不到 Ionic 4 和 Firebase 页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52538082/