angularfire icon indicating copy to clipboard operation
angularfire copied to clipboard

Auth Emulator not enabled until "connectAuthEmulator" is called

Open rlacatus opened this issue 2 years ago • 1 comments

Version info

Angular: ~13.3.4 Firebase: 9.7.0 AngularFire: ^7.3.0

How to reproduce these conditions

Follow instructions here: LINK

Expected behavior

Connects to emulator at localhost:9099

Actual behavior

Connects to Firebase emulator

Issue is fixed by

When using connectAuthEmulator(getAuth(), "http://localhost:9099"); in an authService of some sort, the app connects to the emulator as expected.

Note: at this point, one can remove { provide: USE_AUTH_EMULATOR, useValue: environment.useEmulators ? ['localhost', 9099] : undefined }, from app.module.ts and it still works.

rlacatus avatar May 16 '22 18:05 rlacatus

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

google-oss-bot avatar May 16 '22 18:05 google-oss-bot

I've been having trouble with using the emulator for the last few weeks and received this bit of code from the firebase-tools group. I had to wrap the connectAuthEmulators with if (environment.useEmulators) and it works with and without the providers specified above.

imports: [
    provideAuth(() => {
      const auth = getAuth();
      if (environment.useEmulators) {
        connectAuthEmulator(auth, 'http://localhost:5005', { disableWarnings: true });
      }
      return auth;
    }),
    provideFirestore(() => {
      const firestore = getFirestore();
      if (environment.useEmulators) {
        connectFirestoreEmulator(firestore, 'localhost', 5006);
      }
      return firestore;
    }),
 ]

It would be nice to have a definitive guide.

brooksdra avatar Oct 09 '22 22:10 brooksdra