我正在从事Angular 6项目。这是我使用--prod
标志,宿主和运行进行构建时遇到的错误。我已经坐了很长时间了。最初以为这可能是firestore软件包的问题,我等了。但是现在更新为Firestore 5.0.4,问题仍然存在。
[2018-06-04T06:11:47.859Z] @ firebase / firestore:Firestore(5.0.4):无法访问Cloud Firestore后端。后端在10秒内未响应。
这通常表明您的设备目前没有正常的Internet连接。客户端将以脱机模式运行,直到能够成功连接到后端为止。
app.module.ts
Imports: [
AngularFireModule.initializeApp(environment.firebaseConfig),
AngularFirestoreModule
]
Run Code Online (Sandbox Code Playgroud)
app.component.ts
constructor(public afAuth: AngularFireAuth,
private afs: AngularFirestore,
private db: AngularFireDatabase) {
this._currentUser = this.afAuth.authState
.pipe(
switchMap((user: any) => {
if (user) {
console.log(user);
return this.afs.collection('users').doc<User>(user.uid).valueChanges();
} else {
return Observable.create(null);
}
})
);
}
Run Code Online (Sandbox Code Playgroud)
仅供参考:身份验证仍然有效。
依赖firebase 5.0.4 angularfire2 5.0.0-rc.10
对标题感到抱歉,我不确定这是否是我面临的正确问题,但是,我会尝试描述我正在尝试做的事情。
我已经更新了标题,因为其中的错误似乎是我的问题(原文:“模拟先行不保存文档?”)。
\n我有一个在产品上使用 Firebase 的 React 应用程序(函数、身份验证、firestore 和存储),我需要更改其中的一些内容,因此,我认为首先在本地进行这些更改然后部署它们会更安全。因此,我设置了 firebase 模拟器套件,并设置应用程序的环境变量以指向本地内容(应用程序的这一部分不需要存储,因此在本地未启用它)。
\n无论如何,我设置了一个本地身份验证帐户,以便我可以登录该帐户并将文档添加到“用户”集合中(这是需要的,因为应用程序会在 firestore 中查找登录用户的文档)但是,看起来当我刷新模拟器 UI 时,firestore 模拟器会删除此文档吗?
\n您可以在这个 GIF 中明白我的意思:Firestore 删除了文档
\n可能需要的其他信息:
\n\xe2\x9d\xaf firebase emulators:start --import ./functions/firestore --export-on-exit \ni emulators: Starting emulators: auth, functions, firestore\n! functions: The following emulators are not running, calls to these services from the Functions emulator will affect production: database, hosting, pubsub, storage\n+ functions: Using node@12 from host.\ni firestore: Importing data from E:\\Project\\api\\functions\\firestore\\firestore_export\\firestore_export.overall_export_metadata\n! firestore: Did not find a Cloud Firestore …
Run Code Online (Sandbox Code Playgroud)