firebase-tools: Hosting doesn't execute function if function region is not default
Version info
4.00
Platform Information
OS X
Steps to reproduce
function deployed to europe-west1
// function code
const functions = require('firebase-functions');
exports.helloIvanA = functions
.region('europe-west1')
.https.onRequest((request, response) => {
response.send('Hello from Ivan!');
});
// firebase.json
{
"hosting": {
"public": "public",
"rewrites": [
{
"source": "**",
"function": "helloIvanA"
}
]
}
}
Expected behavior
https://blablabla.firebaseapp.com
will get data from helloIvanA
Actual behavior
https://blablabla.firebaseapp.com
redirects to https://us-central1-yushkarala.cloudfunctions.net/helloIvanA/
and gives
Error: Forbidden Your client does not have permission to get URL /helloIvanA/ from this server.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 30
- Comments: 41 (11 by maintainers)
Would love to see this implemented. My visitors are from Europe, and the TTFB from
us-central1
is at least 3x bigger thaneurope-west1
.A warning in bold should be written until this is fixed. I’ve spent too much time until I realized what happens. At least add a
region
option to the rewrites so we can redirect to europe.Hi @laurenzlong ,
does that mean that when Hosting will be available through other locations that
us-central1
, we’ll also be able to bypass the following limitation ?Important: If you are using HTTP functions to serve dynamic content for hosting, you must use us-central1.
from docI need that feature for my application. So, the sooner, the better 😃!
Thanks a lot for all this.
Really don’t know why this issue has been closed if it has been not resolved, bumping +1.
Hi, it will change in a future, but not in the near future. It depends on when Firebase Hosting launch origins in other geographies.
Second this, Firebase is amazing, but for European users this is a major caveat.
Lets help each other out by doing as they ask - post a feature request: https://firebase.google.com/support/troubleshooter/report/features
Here’s a draft for you to copy/paste from - just get it done 😃
Would like to see europe-region support too.
@mbleigh - Please could you give us any estimates when Hosting origin will be located outside of US?
The whole Firebase environment is amazing, but this make us think twice before switching to it. Thank you
Hello, My problem is very similar to this, but my functions should be in the EU, as it uses external network, and the latency is much better in this way (2-4 sec vs 4-600 ms) execution time Described my problem in: https://github.com/firebase/firebase-js-sdk/issues/1101 so there is no solution yet to use rewrites to an other region at the moment? ( I’ve a workaround, using direct links to reach the EU function, but that not ideal from development side, I need to redeploy everything to test it out)
Would be a great thing to have this, we could finally add a hosting rewrite to our functions already living in europe-west1.
Would be great indeed. For now, also using redirects as @hgghyxo mentioned:
Function name
api
Regioneurope-west1
firebase.json
Sorry but a tiny blue box is easily missed. We’ve wasted too many hours on this problem, thinking it was a configuration problem in our end.
Sorry, we can’t comment on timelines as they are a little too subject to change. I appreciate the ongoing voice for supporting this as a feature, that’s definitely something we take into account as we plan and build the product.
Two years after and this is still a problem… Why is this closed by the way?
Here hoping for this feature soon!
I’m close to giving up on firebase because of the bad documentation.
An absolute minimum would be to issue a warning if there is no function in us-central matching the function in the redirect!
I suggest the firebase team tries to let someone develop a project where the users are outside the US. It’s crazy that we don’t get warnings for this kind of stuff.
We’re still looking into this but right now our origin infrastructure is concentrated in
us-central
which means that allowing function proxying in other regions would end up creating extra latency in most cases. For instance:This means that the round trip time actually does something like doubling.
We are investigating expanding the locations of our origin infrastructure, but until then we’re wary about adding this capability as it is more likely to cause harm than good.
Hi, this is expected behavior, please see https://firebase.google.com/docs/functions/locations#http_and_client_callable_functions, the blue box indicates that all functions that serve as hosting redirects must be in ‘us-central1’, this is due to the fact that that’s where the hosting origin is.
Has anyone researched into using cloud run instead of cloud functions ?
Cloud run provides functionalities in other regions also
Yes – if you send a feature request, we will deduplicate it against other ones for our internal tracking (and it definitely helps to show more support for requests!).
It seems that a rewrite can now be made with a Cloud Run service hosted on
europe-west1
region (currently the only europe region available for Cloud Run). It’s not quite the same, but pretty close.