【问题标题】:Firebase hosting connect to cloud function in *europe-west1*Firebase 托管连接到 *europe-west1* 中的云功能
【发布时间】:2020-01-09 11:56:24
【问题描述】:

我在 Google Cloud Functions (https://europe-west1-myproject-name.cloudfunctions.net/api/v1/ical.ics) 上设置了一个 api。 这很好用,但我希望为 api 设置一个“友好”的域名。 :)

根据谷歌documentation 的说法,这似乎很容易,但它似乎不适用于美国以外的云功能,例如。欧洲西部1.

我已根据文档使用以下代码更新了firebase.json 文件。

  "hosting": {
    "public": "public",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ],
    "rewrites": [
      {
        "source": "/api/**",
        "function": "api"
      },
      {
        "source": "**",
        "destination": "/index.html"
      }
    ]
  }

访问https://myproject-name.web.app/api/v1/ical.ics时 我被重定向到 https://us-central1-myproject-name.cloudfunctions.net/api/api/v1/cal.ics 并出现错误 403 和以下错误消息。

Error: Forbidden
Your client does not have permission to get URL /api/api/ical.ics from this server.

我必须在这里忽略一些非常基本的东西,因为这似乎是一个非常简单的操作? :)

亲切的问候 /K

【问题讨论】:

  • 没有解决方法。它只是在 us-central1 之外不受支持。
  • 这对很多人来说是不幸的。一件事是数据规则(gdpr),另一件事是在美国运行功能而在其他地方(例如欧洲)托管/数据库时非常严重的延迟问题。

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


【解决方案1】:

documentation 中所述(见蓝色文本块):

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


您还会在doc 中找到类似的警告,您在“使用云功能提供动态内容和托管微服务”的问题中提到(也请参见蓝色文本块):

Firebase 托管仅在 us-central1 中支持 Cloud Functions。

【讨论】:

  • 感谢您的简洁回答!我一定会尝试的。 (^__^)/
  • 通过美国数据中心提供数据时要遵守 GDPR 限制。
【解决方案2】:

这并不完全是您正在寻找的答案,因为 Firebase 托管无法实现。 但是可以使用Cloud Run 在您托管在欧盟的云功能前获得一个自定义域。 我遵循了本指南: https://cloud.google.com/endpoints/docs/openapi/get-started-cloud-functions

然后我在Cloud RunManage custom domains 下添加了自定义域。

【讨论】:

  • 谢谢!我肯定会考虑使用自定义域和 Cloud Run! /K
猜你喜欢
  • 2020-06-13
  • 2020-12-27
  • 2018-08-07
  • 1970-01-01
  • 2018-04-11
  • 2020-10-14
  • 1970-01-01
  • 2017-12-11
  • 2017-08-14
相关资源
最近更新 更多