【问题标题】:Firebase Hosting proxy to Cloud Functions only triggers in us-central1Cloud Functions 的 Firebase 托管代理仅在 us-central1 中触发
【发布时间】:2020-01-29 12:40:19
【问题描述】:

我使用区域:asia-northeast1 创建了我的 firebase 云函数,我正在尝试使用 firebase.json 文件触发其中一个函数。

  "hosting": [
    {
      "target": "ksite",
      "public": "public",
      "ignore": [
        "firebase.json",
        "**/.*",
        "**/node_modules/**"
      ],
      "rewrites": [
        { "source": "**", "function": "ssr" }
      ]
    }
  ]

不幸的是,这会触发区域为us-central1 https://us-central1-site.cloudfunctions.net/ssr/ 而不是asia-northeast1 之类的函数https://asia-northeast1-site.cloudfunctions.net/ssr/

这是如何以及为什么会发生的?

这是我的功能:

// For Universal Rendering
export const ssr = functions.region('asia-northeast1').https.onRequest((request, response) => {
    require(`${process.cwd()}/dist/ksite-webpack/server`).app(request, response);
});

【问题讨论】:

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


    【解决方案1】:

    Firebase Hosting 目前仅支持代理 URL 到部署到 us-central1 的函数,如 documentation 中所述:

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

    还有here in the docs:

    重要提示:如果您使用 HTTP 函数为 Firebase 托管提供动态内容,则必须使用 us-central1。

    【讨论】:

    • 这太疯狂了……现在是 2020 年 6 月,情况还是一样。绝对是疯子。它会自动使许多网站对美国以外的公司无用。通过函数进行服务器端渲染在美国以外是不可行的。精神错乱
    • @Spock 随时向 Firebase 支持提出功能请求。 support.google.com/firebase/contact/support
    • @Dough 我相信他们知道......他们甚至在文档中提到函数仅适用于美国(如果它是 http 函数)......所以欧洲没有人可以使用函数。 . 这意味着没有服务器端渲染,没有 api,没有微服务.. 我们必须将全节点服务器部署到 App Engine..
    • @Spock 您可以改用 Cloud Run。
    • @Dough 谢谢,是的,我已经想到了,现在我将节点服务器部署到 App Engine,它很适合我.. 但是 Cloud Run 看起来很有希望.. 谢谢
    猜你喜欢
    • 2021-04-10
    • 2019-11-01
    • 2020-07-05
    • 1970-01-01
    • 2023-02-18
    • 2017-11-03
    • 2018-10-16
    • 1970-01-01
    • 2018-01-10
    相关资源
    最近更新 更多