I successfully upgraded AngularFire to version 16 and now I want to use the emulator with modular mode. I tried setting it up like in the example provided in the official samples found here: https://github.com/angular/angularfire/blob/master/samples/modular/src/app/app.module.ts
This is a snippet of my app.module.ts:
@NgModule({
declarations: [
// .. //
],
imports: [
provideFirebaseApp(() => initializeApp(environment.firebaseConfig)),
provideAuth(() => {
const auth = getAuth();
if (environment.useEmulators) {
connectAuthEmulator(auth, 'http://localhost:9099', {disableWarnings: true});
}
return auth;
}),
provideFirestore(() => {
const firestore = getFirestore();
if (environment.useEmulators) {
connectFirestoreEmulator(firestore, 'localhost', 8080);
}
enableMultiTabIndexedDbPersistence(firestore).then(
() => resolvePersistenceEnabled(true),
() => resolvePersistenceEnabled(false)
);
return firestore;
}),
provideFunctions(() => {
const functions = getFunctions();
if (environment.useEmulators) {
connectFunctionsEmulator(functions, 'localhost', 5001);
}
return functions;
}),
// .. //
],
providers: [
{
provide: FIREBASE_OPTIONS, useValue: environment.firebaseConfig
},
],
bootstrap: [AppComponent],
})
export class AppModule {
}
With this I am able to login to my application using credentials from the auth emulator. But as soon as the app is being hotreloaded, i get following error in the console:
ERROR Error: Uncaught (in promise): FirebaseError: Firebase: Auth instance has already been used to make a network call. Auth can no longer be configured to use the emulator. Try calling "connectAuthEmulator()" sooner. (auth/emulator-config-failed).
I would appreciate any help with this issue.
What I found so far is that upon login, the first call to the identity toolkit is correctly directed towards localhost.
http://localhost:9099/identitytoolkit.googleapis.com/v1/accounts:lookup?key={{myKey}}
but when reloaded it is directed towards production
https://identitytoolkit.googleapis.com/v1/accounts:lookup?key={{myKey}}