或AngularFireAuth指向身份验证模拟器

或AngularFireAuth指向身份验证模拟器

本文介绍了如何配置AngularFireAuthModule和/或AngularFireAuth指向身份验证模拟器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我相信auth模拟器是在2020年10月底附近发布的. auth模拟器功能要求我正在尝试通过对本地主机:9099进行angular/fire/auth调用来配置本地服务的angular应用程序以使用auth仿真器.那有可能吗?或者是角力/射击团队目前正在为此工作?

I believe the auth emulator was released near the end of Oct. 2020. auth emulator feature reqeustI'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?

我在环境中的firebase配置参数是:

My firebase config parameter in environment is:

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

我将auth仿真器端口localhost:9099放置在authDomain中,但这并不能解决问题.

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

在我的app.module.ts文件AngularFireModule.initializeApp(environment.firebase)的import部分中,将firebase对象传递给angularfire.

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

要使用功能仿真器,我从angular/fire/functions包中导入了ORIGIN,并使其启动并运行.此处为文档.我还看到了SETTINGS导入,可用于将Firesore指向仿真器.我在文档有关如何将auth调用指向auth仿真器.

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.

推荐答案

虽然我认为这不是最好的地方,但这对我来说在我的服务构造函数中很有效:

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');
}

这篇关于如何配置AngularFireAuthModule和/或AngularFireAuth指向身份验证模拟器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-27 10:38