Home > database >  Does Firebase Cloud Functions's HTTP onRequest handler only work with us-central1?
Does Firebase Cloud Functions's HTTP onRequest handler only work with us-central1?

Time:04-06

I have a Cloud Function called customIndexHtml like so:

exports.customIndexHtml = functions.region('asia-east2').https.onRequest((req, res) => {
    //return a customized HTML
}

Right now it would only work if I remove the region setting and leave it to the default us-central1 server. The function would work, but the latency is high because my app is based in Asia. I've tried the Asian servers closer to me (Singapore, Hongkong), but every time I specify them and try to run, Firebase Cloud Functions would redirect my app to https://uc.appengine.google.com/. My question is, is there anyway to make https.onRequest work with regions other than us-central1?

Note that this is only happening if I am using the https.onRequest() handler, if I use any other handler and specify a region closer to me, it works just fine.

CodePudding user response:

You can deploy a Firebase Function to a specific location, as per your snippet.

But you also need to give instructions to your client:

There is also one important notice: If you are using HTTP functions to serve dynamic content for Firebase Hosting, you must use us-central1.

  • Related