How to configure AngularFireAuthModule and/or AngularFireAuth to point to auth emulator

我是研究僧i 提交于 2021-02-10 06:49:06

问题


I believe the auth emulator was released near the end of Oct. 2020. auth emulator feature reqeust I'm trying to configure my locally served angular app to use the auth emulator by having angular/fire/auth make calls to localhost:9099. Is that possible yet? Or is the angular/fire team currently working on this?

My firebase config parameter in environment is:

firebase: {
    host: 'localhost:5000',
    ssl: false,
    apiKey: '<redacted>',
    authDomain: 'localhost:9099',
    databaseURL: '',
    projectId: '<redacted>',
    storageBucket: '',
    messagingSenderId: ''
  }

I placed the auth emulator port localhost:9099 in authDomain but that doesn't do the trick.

I pass the firebase object to angularfire in the import section of my app.module.ts file AngularFireModule.initializeApp(environment.firebase);

To use the functions emulator I imported ORIGIN from the angular/fire/functions package and have that up and running. doc here. I also saw SETTINGS import for use to point the Firesore to the emulator. I can't find anything in the docs on how to point the auth calls to the auth emulator.


回答1:


Although I think it's not the best place, this worked for me inside my service constructor:

constructor(private _angularFireAuth: AngularFireAuth) {
  this._angularFireAuth.useEmulator('http://localhost:9099');
}



回答2:


This documentation can provide one best praticte like than constructor implementation. I am using in my project and worked perfectly



来源:https://stackoverflow.com/questions/64656725/how-to-configure-angularfireauthmodule-and-or-angularfireauth-to-point-to-auth-e

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!