0
votes

I would like to request an API which only allow IP from Hong Kong, therefore I perform a check using https://ifconfig.co/country-iso. Even I set functions.region('asia-east2') as stated in the document page (https://firebase.google.com/docs/functions/locations), the console logged the location detected is US

  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

1 Answers

0
votes

If you are using scheduled functions, as you are, then you have an App Engine machine that is required for Cloud Scheduler to work. I think that the default project region might be set to something else than 'asia-east2' that you want.

If the function is set correctly to asia-east2 the only other regional config that can affect is the default project region where the App Engine machine spins up, I think that might be your issue.

Here you have more information on scheduled functions and the information I mentioned about the App Engine machine.

And here you can see more information about default project location.

Let me know.