FirebaseError: Firebase: A network AuthError (such as timeout, interrupted connection or unreachable host) has occurred. (auth/network-request-failed)
FirebaseError: Firebase: A network AuthError (such as timeout, interrupted connection or unreachable host) has occurred. (auth/network-request-failed)
我想设置我的 Angular 应用程序以使用 Firebase 的模拟器并按照 this guide 设置我的 app.module.ts
如下:
import { USE_EMULATOR as USE_AUTH_EMULATOR } from '@angular/fire/compat/auth';
import { USE_EMULATOR as USE_DATABASE_EMULATOR } from '@angular/fire/compat/database';
import { USE_EMULATOR as USE_FIRESTORE_EMULATOR } from '@angular/fire/compat/firestore';
@NgModule({
// ... Existing configuration
providers: [
// ... Existing Providers
{ provide: USE_AUTH_EMULATOR, useValue: environment.useEmulators ? ['http://localhost', 9099] : undefined },
{ provide: USE_DATABASE_EMULATOR, useValue: environment.useEmulators ? ['http://localhost', 9000] : undefined },
{ provide: USE_FIRESTORE_EMULATOR, useValue: environment.useEmulators ? ['http://localhost', 8080] : undefined },
]
})
export class AppModule { }
运行firebase emulators:start
和ng serve
之后都没有错误。如果我尝试登录,我会在 Chrome 中收到以下错误:FirebaseError: Firebase: A network AuthError (such as timeout, interrupted connection or unreachable host) has occurred. (auth/network-request-failed)
。还有一个失败的网络请求:POST http://localhost/identitytoolkit.googleapis.com/v1/accounts:signUp?key=API_KEY net::ERR_CONNECTION_REFUSED
如果我在 FireFox 中尝试相同的操作,我会收到此错误:Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://localhost/identitytoolkit.googleapis.com/v1/accounts:signUp?key=API_KEY. (Reason: CORS request did not succeed)
以及我在 Chrome.
中收到的错误
我遵循的指南说使用 localhost
而不是 http://localhost
尽管当页面加载时,我在 DevTools 控制台中收到错误 FirebaseError: Firebase: Emulator URL must start with a valid scheme (http:// or https://). (auth/invalid-emulator-scheme)
。我正在使用 "@angular/fire": "^7.0.3"
我该怎么做才能解决这个问题?
我通过降级到 @angular/fire
v6
设法解决了这个问题
我想设置我的 Angular 应用程序以使用 Firebase 的模拟器并按照 this guide 设置我的 app.module.ts
如下:
import { USE_EMULATOR as USE_AUTH_EMULATOR } from '@angular/fire/compat/auth';
import { USE_EMULATOR as USE_DATABASE_EMULATOR } from '@angular/fire/compat/database';
import { USE_EMULATOR as USE_FIRESTORE_EMULATOR } from '@angular/fire/compat/firestore';
@NgModule({
// ... Existing configuration
providers: [
// ... Existing Providers
{ provide: USE_AUTH_EMULATOR, useValue: environment.useEmulators ? ['http://localhost', 9099] : undefined },
{ provide: USE_DATABASE_EMULATOR, useValue: environment.useEmulators ? ['http://localhost', 9000] : undefined },
{ provide: USE_FIRESTORE_EMULATOR, useValue: environment.useEmulators ? ['http://localhost', 8080] : undefined },
]
})
export class AppModule { }
运行firebase emulators:start
和ng serve
之后都没有错误。如果我尝试登录,我会在 Chrome 中收到以下错误:FirebaseError: Firebase: A network AuthError (such as timeout, interrupted connection or unreachable host) has occurred. (auth/network-request-failed)
。还有一个失败的网络请求:POST http://localhost/identitytoolkit.googleapis.com/v1/accounts:signUp?key=API_KEY net::ERR_CONNECTION_REFUSED
如果我在 FireFox 中尝试相同的操作,我会收到此错误:Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://localhost/identitytoolkit.googleapis.com/v1/accounts:signUp?key=API_KEY. (Reason: CORS request did not succeed)
以及我在 Chrome.
我遵循的指南说使用 localhost
而不是 http://localhost
尽管当页面加载时,我在 DevTools 控制台中收到错误 FirebaseError: Firebase: Emulator URL must start with a valid scheme (http:// or https://). (auth/invalid-emulator-scheme)
。我正在使用 "@angular/fire": "^7.0.3"
我该怎么做才能解决这个问题?
我通过降级到 @angular/fire
v6