Emulator url will be ignored and call to cloudfunctions.net instead when setting region.
firebase.functions().useFunctionsEmulator("http://localhost:5001");
// This will call to cloudfunctions.net
firebase.app().functions("asia-east2").httpsCallable(<FnName>);
// This will call to localhost
firebase.app().functions().httpsCallable(<FnName>);
I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
Thanks for reporting, @ThewBear. It looks like an intended behavior as it's meant to test the function locally, the region isn't being observed. It's not until you deploy it that you can invoke it in the given region. The deployed URL should have the region in the hostname part of the URL, not in the path as you get the emulator.
So my current workaround is
if (process.env.NODE_ENV === "development") {
firebase.app().functions().httpsCallable(<FnName>);
} else {
firebase.app().functions("asia-east2").httpsCallable(<FnName>);
}
I think it would be better if I can give a region and firebase ignores it when using emulator.
This is already working in firebase-functions.
Thanks for letting us know your workaround, @ThewBear. While this is currently an intended behavior, we'll treat this as a feature request and keep this open.
+1
+1 馃憤
+1
I was using firebase.functions().useFunctionsEmulator(environment.emulator) globally, so to keep the changes to a minimum I used this as a workaround:
firebase.app().functions(environment.emulator ? undefined : 'europe-west1').httpsCallable(<FnName>)
Most helpful comment
Thanks for letting us know your workaround, @ThewBear. While this is currently an intended behavior, we'll treat this as a feature request and keep this open.