【问题标题】:firebase hosting not passing to firebase function despite re-write尽管重写,firebase 托管未传递给 firebase 功能
【发布时间】:2020-11-10 17:22:34
【问题描述】:

完整回购:https://github.com/jmsherry/firebase-full

firebase.json

{
  "hosting": {
    "predeploy": [
      "npm --prefix webapp run build"
    ],
    "public": "webapp/build",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ],
    "rewrites": [
      {
        "source": "/server-time",
        "function": "serverTime"
      },
      {
        "source": "**",
        "destination": "/index.html"
      }
    ]
  },
  "firestore": {
    "rules": "firestore.rules",
    "indexes": "firestore.indexes.json"
  }
}

我正在尝试将我的功能与托管一起使用。该功能可用(网址:https://europe-west2-full-firebase-efc5a.cloudfunctions.net/serverTime),但服务器时间功能的重写在本地工作,但在托管它 404 的 Firebase 上运行并重定向到主页(网址:https://full-firebase-efc5a.firebaseapp.com/server-time

好像它没有被发送到firebase端的函数!

谁能解释一下?

【问题讨论】:

    标签: firebase google-cloud-functions firebase-hosting


    【解决方案1】:

    您似乎已将您的功能部署到区域 europe-west2。不幸的是,这根本不适用于生产环境中的 Firebase 托管,因为它仅支持用于 Cloud Functions 的 us-central1。来自documentation中的注释:

    重要提示:Firebase 托管仅在 us-central1 中支持 Cloud Functions。

    考虑改用Cloud Run。它的工作量更大,但您将能够部署到任何受支持的区域,并且可以与 Firebase 托管一起使用。

    【讨论】:

      猜你喜欢
      • 2020-05-14
      • 2018-04-11
      • 2020-06-13
      • 2018-11-12
      • 1970-01-01
      • 2020-12-27
      • 2017-12-11
      • 2018-08-07
      • 2018-10-31
      相关资源
      最近更新 更多