firebase部署到自定义区域(eu-central1)

问题描述 投票:23回答:2

有没有办法指定将部署我的firebase功能的区域/区域。

实际上我没有在文档中找到任何关于它的内容,我的功能总是部署到我们 - central1但我希望在eu-central1上有...

是否可以在Firebase - Config - File中设置它?

{
  "database": {
    "rules": "database.rules.json"
  },
  "hosting": {
    "public": "public",
    "rewrites": [
      {
        "source": "**",
        "destination": "/index.html"
      }
    ]
  }
}

我也看了一下cli选项,但我没有找到任何东西。

Firebase项目本身已正确设置为欧洲区域o.O.

提前致谢

firebase google-cloud-functions
2个回答
18
投票

这里有一个firebaser

更新(2018-07-25):

现在,您可以在Firebase中指定云功能的区域,在代码中指定该区域并部署更改。例如。:

exports.myStorageFunction = functions
    .region('europe-west1')
    .storage
    .object()
    .onFinalize((object) => {
      // ...
    });

有关详细信息,请参阅Firebase documentation on Cloud Functions locations(从我获得上述代码段)和modifying the region of a deployed function


9
投票

来自docs:https://firebase.google.com/docs/functions/locations

现在可在以下地区使用:

  • us-central1(爱荷华州)
  • us-east1(南卡罗来纳州)
  • europe-west1(比利时)
  • asia-northeast1(东京)

Best Practices for Changing Region

// before
const functions = require('firebase-functions');

exports.webhook = functions
    .https.onRequest((req, res) => {
            res.send("Hello");
    });

// after
const functions = require('firebase-functions');

exports.webhookEurope = functions
    .region('europe-west1')
    .https.onRequest((req, res) => {
            res.send("Hello");
    });
© www.soinside.com 2019 - 2024. All rights reserved.