Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hosting doesn't execute function if function region is not default #842

Closed
istarkov opened this issue Jul 28, 2018 · 41 comments
Closed

Hosting doesn't execute function if function region is not default #842

istarkov opened this issue Jul 28, 2018 · 41 comments

Comments

@istarkov
Copy link

istarkov commented Jul 28, 2018

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.

@istarkov
Copy link
Author

Also example repo https://github.com/istarkov/firebase-hosting-error

@laurenzlong
Copy link
Contributor

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.

@istarkov
Copy link
Author

Thank you, any chance that this expected behaviour will be changed in near future or at least in a future?

@laurenzlong
Copy link
Contributor

Hi, it will change in a future, but not in the near future. It depends on when Firebase Hosting launch origins in other geographies.

@hgghyxo
Copy link

hgghyxo commented Aug 9, 2018

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:
firebase/firebase-js-sdk#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)

@diogoterremoto
Copy link

Would love to see this implemented. My visitors are from Europe, and the TTFB from us-central1 is at least 3x bigger than europe-west1.

@johanchouquet
Copy link

Hi, it will change in a future, but not in the near future. It depends on when Firebase Hosting launch origins in other geographies.

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 doc

I need that feature for my application. So, the sooner, the better :)!

Thanks a lot for all this.

@vovahost
Copy link

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.

@wangchou
Copy link

wangchou commented Jun 1, 2019

Hope cloud function for Firebase support region option like cloud run setting did. I'm using tokyo region. It is really far from us-central1.

@johanchouquet
Copy link

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 doc

Hi @laurenzlong ,

do you have any (good)? news about this ?

I agree that as @wangchou said, cloud run would be an alternative, but it adds stack of services / technology.

Hoping to read you soon. Thanks!

@mbleigh
Copy link
Contributor

mbleigh commented Jun 5, 2019

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:

tokyo -> CDN edge -> origin (us-central) -> function (tokyo)

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.

@fazpu
Copy link

fazpu commented Jul 27, 2019

@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

@danieldanielecki
Copy link

Really don't know why this issue has been closed if it has been not resolved, bumping +1.

@suzukieng
Copy link

Second this, Firebase is amazing, but for European users this is a major caveat.

@mbleigh
Copy link
Contributor

mbleigh commented Jul 29, 2019

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.

@lborgman
Copy link

lborgman commented Aug 6, 2019

I have an issue that might be related to this, but I do not fully understand this so I do not know. If someone who knows better and have time wants to comment on that, please see this question:

https://stackoverflow.com/questions/57367131/403-from-deployed-firebase-function

@shovelend
Copy link

Would be a great thing to have this, we could finally add a hosting rewrite to our functions already living in europe-west1.

@mcoevert
Copy link

Would be great indeed. For now, also using redirects as @hgghyxo mentioned:

Function name api
Region europe-west1

firebase.json

"redirects": {
    {
          "source": "/api/endpoint",
          "destination": "https://europe-west1-project-id.cloudfunctions.net/api/endpoint",
          "type": 301
    },
    ...
}

@Karasuni
Copy link
Contributor

@mcoevert commented on Aug 19, 2019, 10:36 AM GMT+2:

Would be great indeed. For now, also using redirects as @hgghyxo mentioned:

Redirects won't solve the CORS issues though.

@LaszloDev
Copy link

Would like to see europe-region support too.

@diogoterremoto
Copy link

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.

@larssn
Copy link

larssn commented Oct 10, 2019

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.

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.

@alfetch
Copy link

alfetch commented Oct 28, 2019

Why is this closed - it's an issue for us in europe. Is there any explanation why it's only working for region us ?

@mbleigh
Copy link
Contributor

mbleigh commented Oct 28, 2019

This issue is closed because it's a feature request for Firebase Hosting that can't be addressed directly in the Firebase CLI. Feature requests are tracked internally and I'd encourage you to request support for additional regions via this form.

We are definitely aware that many of you want this feature, thanks for the feedback!

@Karasuni
Copy link
Contributor

This issue is closed because it's a feature request for Firebase Hosting that can't be addressed directly in the Firebase CLI. Feature requests are tracked internally and I'd encourage you to request support for additional regions via this form.

We are definitely aware that many of you want this feature, thanks for the feedback!

Feature requests are only tracked internally? Doesn't that bring a lot of duplicate requests? I'd like to show support for these features to include non-US regions.

@mbleigh
Copy link
Contributor

mbleigh commented Oct 28, 2019

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!).

@alexlobera
Copy link

alexlobera commented Nov 3, 2019

You could use Cloud Run instead of a Cloud Function if you don't need a VPC.  Cloud Run (fully managed) cannot connect to VPC network currently. A workaround I've tested to use the VPC + custom domain + Cloud Function is to use a Cloud Run with a custom domain which is a proxy to the Cloud Function. It adds a bit of overhead but if your Cloud Run and Cloud  Function are in the same region then, in theory, it shouldn't be much latency. That being said, I've monitored it over a month and Cloud Run beta is not 100% that stable: 

image

This is a repo with the proxy I've used if you want to deploy it to Cloud Run and give it a try https://github.com/reactgraphqlacademy/cloud-run-proxy

I've tested a Cloudflare worker with a proxy in the same region that the Cloud Function and monitored it over the same period.  It was slower than the Cloud Run, although it was 100% reliable.

image

You can use this code if you want to test the Cloudflare worker https://gist.github.com/alexlbr/814446f03cf12e22f07ccaa580eb1154. @wangchou If I'm not mistaken, you could run the Cloudflare worker in Tokio, so it can be closer to the edge where the user is since Cloud Run is not supported yet in that region.

The following monitors the Cloud Function directly without any proxy during the same period.

image

I've used https://uptimerobot.com for the monitoring.

Cloud Run looks very promising to me, I can't wait to the full release

@abdellahaski
Copy link

abdellahaski commented Dec 5, 2019

Any updates on this ? Why it's closed ?

@l2aelba
Copy link

l2aelba commented Dec 5, 2019

Impossible?

@bkendall
Copy link
Contributor

bkendall commented Dec 5, 2019

@abdellahaski @l2aelba We definitely hear the pain point here. As @mbleigh said earlier, filing it as a feature request (see below) is the best way to help this gain traction for us internally. Thanks!

This issue is closed because it's a feature request for Firebase Hosting that can't be addressed directly in the Firebase CLI. Feature requests are tracked internally and I'd encourage you to request support for additional regions via this form.

We are definitely aware that many of you want this feature, thanks for the feedback!

@mbizplus
Copy link

mbizplus commented Dec 6, 2019

Would like to see asia-east2 support too.

@alexanderkjeldaas
Copy link

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.

@denkan
Copy link

denkan commented Dec 20, 2019

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 :)

Hosting rewrites to functions in non-US region
#842

Really need to be able to create rewrites to functions in regions other than US-Central1.

Our target audience is not in US and the lack of this feature is a great painpoint to us, making us uncertain to dedicate our tech-stack to Firebase overall.

Please do consider prioritize this feature in near future.
Thank you,

image

@martimors
Copy link

Here hoping for this feature soon!

@mc-lovin
Copy link

mc-lovin commented Mar 1, 2020

Has anyone researched into using cloud run instead of cloud functions ?

Cloud run provides functionalities in other regions also

@Gennttii
Copy link

Gennttii commented Apr 8, 2020

Two years after and this is still a problem.. Why is this closed by the way?

@Karasuni
Copy link
Contributor

Karasuni commented Apr 8, 2020

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.

Paging @laurenzlong

Cloud Functions is available in the following regions:

  • us-central1 (Iowa)
  • us-east1 (South Carolina)
  • us-east4 (Northern Virginia)
  • europe-west1 (Belgium)
  • europe-west2 (London)
  • europe-west3 (Frankfurt)
  • asia-east2 (Hong Kong)
  • asia-northeast1 (Tokyo)

@Gennttii
Copy link

Gennttii commented Apr 8, 2020

I choosed eur3 (europe-west) because it was in top of the list together with us-central1, and separeted from other locations. Thought these two are default.

What should I do , is there any fix on this?

@fugi
Copy link

fugi commented Apr 9, 2020

Why?????

@mbleigh
Copy link
Contributor

mbleigh commented Apr 9, 2020

Hi folks, thanks for all the feedback on this. We definitely hear you that you'd like to see Firebase Hosting support functions outside of us-central1. Unfortunately there's a significant amount of infrastructure work that has to happen before it would work well, so we can't just "flip a switch" and bring other regions online.

We've heard about this quite often as a feature request, and it's on our roadmap though I can't comment on specific timelines. This repository is not the correct place to post feature requests for the Firebase Hosting product as a whole -- if you are interested in this feature, please submit a feature request so that we can continue to track the interest in this internally and prioritize the work that needs to happen to enable it.

Thanks all!

@Gennttii
Copy link

Gennttii commented Apr 9, 2020

Hi,

I think noone cares where you host, we want just a simple fix so that error won't show.

This fix can be done in your code, nothing to do where you do your hosting..

And this is not request for a feature, the removal of a bug doesn't become a feature. Just remove that bug

Thanks..

@firebase firebase locked as resolved and limited conversation to collaborators Apr 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests