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

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

问题描述:

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

I'm creating Angular 9 Univeral app with Firebase. After the deployment (SSR and non-SSR versions) I started facing the problem:

  • 当我去主要路线(/),然后再去其他任何路线时- 一切正常
  • 当我打开任何路线时(/article 示例),然后强制重新加载页面(CTRL + SHIFT + R),我得到一个 500错误
  • when I go to the main route (/) and then to any other route - everything works fine
  • when I open the any route (/article for example) and then force reload the page (CTRL + SHIFT + R) I get an 500 error

我的firebase.json:

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

这是控制台上的错误

Here is an error at the console

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

I don't have this error at my local machine and I don't know why it happens at the server. Any advises?

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

I had problem with ssr cloud function. It didn't deploy because of error so when I changed my firebase.json to the following one, my routing started working again.

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