为什么在部署Angular 9 + Firebase应用程序后出现路由错误

问题描述 投票:0回答:1

我正在使用Firebase创建Angular 9 Univeral应用。部署后(SSR和非SSR版本),我开始面对问题:

  • 当我去主要路线(/),然后再去其他任何路线时-一切正常
  • 当我打开任何路线时(/article示例),然后强制重新加载页面(CTRL + SHIFT + R),我得到一个500错误

enter image description here

我的firebase.json

{
  "firestore": {
    "rules": "firestore.rules",
    "indexes": "firestore.indexes.json"
  },
  "hosting": {
    "public": "dist/dailycoding/browser",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ],
    "rewrites": [
      {
        "source": "**",
        "function": "ssr"
      }
    ]
  }
}

这里是控制台错误enter image description here

我的本地计算机上没有此错误,我也不知道为什么在服务器上发生此错误。有什么建议吗?

angular firebase angular2-routing angular9
1个回答
0
投票

我对ssr云功能有疑问。它由于错误而没有部署,因此当我将firebase.json更改为下一个时,我的路由重新开始工作。

{
  "firestore": {
    "rules": "firestore.rules",
    "indexes": "firestore.indexes.json"
  },
  "hosting": {
    "public": "dist/dailycoding/browser",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ],
    "rewrites": [
      {
        "source": "**",
        "destination": "/index.html"
      }
    ]
  }
}
© www.soinside.com 2019 - 2024. All rights reserved.