Reputation: 21
I'm having trouble setting the functions-region with angularfire 7.3.0.
I'm importing the modules using v7 modular, and I can't seem to find good instructions on how to change the functions region when using this method.
What I've tried:
Using compat
:
import { AngularFireFunctionsModule, REGION } from '@angular/fire/functions';
...
providers: [
...
{ provide: REGION, useValue: 'europe-west1' }
]
Using getFunctions
:
provideFunctions(() => getFunctions(getApp(), 'europe-west1'));
Both seem to fail to set the region, although the last method is described as the correct one.
When checking the FunctionsInstances I get this: FunctionsInstances
This seems to indicate that the region is set correctly, but when calling a function I get an error saying that https://us-central1-APPNAME.cloudfunctions.net/FUNCTIONNAME
is not available, as it clearly tries to call a function from us-central1
.
Have anybody dealt with this problem, have a fix/workaround or some insight as to why this happens?
Upvotes: 1
Views: 800
Reputation: 21
Ok, so it seems like you have to provide the instance in FunctionsInstance manually.
When defining the functions, do as such:
import { Functions, httpsCallable, FunctionsInstances } from '@angular/fire/functions'
...
// Inject Functions, FunctionsInstances
...
const functionsInstance = this.functionsInstances[0];
someFunction = httpsCallable(functionsInstance, 'someFunction');
By using a function-instance from the FunctionsInstance
instead of getFunctions()
, the call is made using the correct function-instance, and therefore the correct region.
Upvotes: 1