angular/angularfire

AngularFire Function, ignore Region setting

Biokimist opened this issue · 2 comments

When using Angular Fire 19.0.0 - Angular 19.1.7 - Firebase function 6.3.2
Function.region are ignore with httpsCallable

appConfig

export const appConfig: ApplicationConfig = {
  providers: [
    provideRouter(routes),
    provideHttpClient(withInterceptorsFromDi()),
    provideAnimationsAsync(),
    provideFirebaseApp(() => initializeApp(environment.firebase)),
    provideAuth(() => {
      const auth: Auth = getAuth(inject(FirebaseApp));
      if (environment.useEmulators) {
        connectAuthEmulator(auth, `http://localhost:${environment.emulatorPorts.auth}`, { disableWarnings: true });
      }
      return auth;
    }),
    provideFirestore(() => {
      const firestore: Firestore = initializeFirestore(inject(FirebaseApp),{
        localCache: persistentLocalCache(),
      });

      if (environment.useEmulators) {
        connectFirestoreEmulator(firestore, '127.0.0.1', environment.emulatorPorts.firestore);
      }

      return firestore;
    }),
    provideFunctions(() => {
      const functions: Functions = getFunctions(inject(FirebaseApp), 'europe-west3');

      if (environment.useEmulators) {
        connectFunctionsEmulator(functions, '127.0.0.1', environment.emulatorPorts.functions);
      }

      return functions;
    }),
    provideStorage(() => {
      const storage = getStorage(inject(FirebaseApp));
      if (environment.useEmulators) {
        connectStorageEmulator(storage, '127.0.0.1', environment.emulatorPorts.storage);
      }
      return storage;
    }),
    [...]
  ],
};
   getFunctions(inject(FirebaseApp), 'europe-west3');

This should link Functions to 'europe-west3'

Usage in service

import {httpsCallable, Functions, HttpsCallableResult} from '@angular/fire/functions';

@Injectable({
  providedIn: 'root'
})
export class MyService {
    constructor(private functions: Functions){}

    public onCall (){
      const doSomething = httpsCallable(this.functions, 'onCallDoSomething');
      const response: HttpsCallableResult<any> = await doSomething();
    }
}

when onCall(), i get this error:

    POST https://us-central1-rentwave-prod.cloudfunctions.net/onCallDoSomething net::ERR_FAILED

us-central1 is the default region.
httpsCallable, doesn't apply region settings and target the wrong region.
Or I may have misunderstood the way to build appConfig

I tried to override the region by adding just before the httpsCallable; With no luck

   this.functions.region = "europe-west3"

IMPACT:

firebase httpsFunction are unavailable if not on us-central1

This issue does not seem to follow the issue template. Make sure you provide all the required information.

Local cash issue, not relate to Angular Fire, the chunk wasn't updated.