【问题标题】:Why do I get an error with routing after deploying my Angular 9 + Firebase application为什么在部署 Angular 9 + Firebase 应用程序后出现路由错误
【发布时间】:2023-04-02 06:27:01
【问题描述】:

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

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

我的firebase.json

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

这是控制台的错误

我的本​​地机器上没有这个错误,我不知道为什么它会发生在服务器上。有什么建议吗?

【问题讨论】:

  • 控制台显示的错误是什么?
  • 显示你的 firebase.json
  • @varman 500 尝试获取时出错
  • 同时添加功能日志
  • 我无法回复,因为我在睡觉。我认为我们的时间不匹配????

标签: angular firebase angular2-routing angular9


【解决方案1】:

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"
      }
    ]
  }
}

【讨论】:

    猜你喜欢
    • 2016-05-01
    • 1970-01-01
    • 2018-02-11
    • 1970-01-01
    • 1970-01-01
    • 2020-09-11
    • 2020-03-01
    • 1970-01-01
    • 2018-08-16
    相关资源
    最近更新 更多