Firebase云功能位置设置

时间:2019-10-04 00:47:55

标签: firebase google-cloud-functions

我想请求一个仅允许来自香港的IP的API,因此我使用https://ifconfig.co/country-iso进行检查。甚至我按照文档页面(https://firebase.google.com/docs/functions/locations)中的说明设置了functions.region('asia-east2'),控制台也记录了检测到的位置是美国

  exports.locationFunction = functions.region('asia-east2').pubsub.schedule('every 1 minutes').onRun((context) => {

    request('https://ifconfig.co/country-iso', function (error, response, body) {

      console.log("RESULTbody:" + body)

    });

    return admin.database().ref("mylocation").set("detection finished");
  });

1 个答案:

答案 0 :(得分:0)

如果您按原样使用调度功能,则您有一台App Engine计算机,Cloud Scheduler才能正常运行。我认为默认项目区域可能会设置为您想要的'asia-east2'以外的其他内容。

如果功能正确设置为asia-east2,那么唯一会影响的区域配置就是App Engine计算机旋转的默认项目区域,我认为这可能是您的问题。

Here,您会获得有关预定功能的更多信息以及我提到的有关App Engine计算机的信息。

然后here可以查看有关默认项目位置的更多信息。

让我知道。