1
votes

I updated the Firebase hosting rule following this document so I can have the cloud function end point using my own domain name. However it seems this only applies to the cloud function deployed in the default region in us-central1.

"hosting": {
 "rewrites": [ {
   "source": "/endpoint",
   "function": "app"
 } ]
}

But whenever my functions are deployed like the following, the aforementioned the custom domain no longer works because it would still forward the requests to us-central1 rather than asia-east2 resulting in a 403 error.

functions.region('asia-east2').https.onRequest((request, response) => {
    response.send("Hello from Firebase!");
});

Does anyone know how this issue could be fixed? Many thanks!

1
It seems like functions for Firebase Hosting are intended to serve dynamic content for Firebase CDN which sources from us-central1. If what you require is a custom domain connecting to the function and do not tightly relied on Firebase CDN, I think you can give Cloudflare a try, setting CNAME on Cloudflare linking to the domain of your funciton in another region. Though not testing yet myself, I'm also finding a solution to this.momocow
Ok, I find out that CNAME won't work. No need to try. stackoverflow.com/a/61969054/8579025momocow

1 Answers

3
votes

The behavior you're observing is expected, and documented. From the Firebase Hosting documentation:

Important: Firebase Hosting supports Cloud Functions in us-central1 only.