I'm currently working on an app using Firebase. When I'm working outside the emulators, everything is working well. However, when I launch the emulators, I'm not able anymore to connect with Google nor any other service, the popup doesn't load.
I am using these packages:
- @angular/fire v. 7.4.1
- firebase v. 9.9.1
Other information:
- I am not receiving any error in the console
- Complete code can be found here, if needed. dev is the main development branch.
Here's the code for the auth.service.ts:
import { Injectable } from '@angular/core';
import { AngularFireAuth } from '@angular/fire/compat/auth';
import { GoogleAuthProvider, AuthProvider } from "firebase/auth"
@Injectable({providedIn: 'root'})
export class AuthService {
constructor(private afAuth: AngularFireAuth) { }
public googleLogin() {
this.loginWithProvider(new GoogleAuthProvider());
}
private loginWithProvider(provider: AuthProvider) {
return this.afAuth.signInWithPopup(provider).then(console.log).catch(console.log)
}
public logout() {
return this.afAuth.signOut();
}
}
And here's the code for app.module.ts:
@NgModule({
declarations: [
AppComponent
// other components...
],
imports: [
BrowserModule,
AppRoutingModule,
BrowserAnimationsModule,
MaterialModule,
AngularFireModule.initializeApp(environment.firebase),
AngularFireAuthModule,
AngularFirestoreModule,
AngularFireFunctionsModule
],
providers: [
{ provide: USE_AUTH_EMULATOR, useValue: environment.useEmulators ? ['https://localhost', 9099] : undefined },
{ provide: USE_FIRESTORE_EMULATOR, useValue: environment.useEmulators ? ['https://localhost', 8080] : undefined },
{ provide: USE_FUNCTIONS_EMULATOR, useValue: environment.useEmulators ? ['https://localhost', 5001] : undefined },
],
bootstrap: [AppComponent]
})
export class AppModule { }
Do you know what might be wrong? Thanks!