[英]Error: Could not reach Cloud Firestore backend after changing from hardcoded data to process.env
I got this error:我收到此错误:
@firebase/firestore: Firestore (9.9.0): Could not reach Cloud Firestore backend. @firebase/firestore:Firestore (9.9.0):无法到达 Cloud Firestore 后端。 Connection failed 1 times.连接失败 1 次。
after chaning my firebase config from从更改我的 firebase 配置后
apiKey: "SecretApiKey",
authDomain: "SecretAuthDomain",
[...]
}
to:到:
const firebaseConfig = {
apiKey: process.env.apiKey,
authDomain: process.env.authDomain,
[...]
}
also I didnt get this error like 2 days ago or when i was making other project with firebase.我也没有像 2 天前或我用 firebase 制作其他项目时那样收到此错误。
I saw that problem on internet and solution was to change to this:我在互联网上看到了这个问题,解决方案是改为:
const firestoreDB = initializeFirestore(firebaseApp, {
experimentalForceLongPolling: true, // this line
useFetchStreams: false, // and this line
})
but this doesnt work also for me and i get another error.但这对我也不起作用,我得到另一个错误。
The error message you encountered usually appears when there is no connection from your device to your database, Possibly due to network issues on your end.当您的设备没有连接到数据库时,通常会出现您遇到的错误消息,可能是由于您端的网络问题。 It also means that there is something that is not allowing the Client application to reach the Firestore backend.这也意味着有些东西不允许客户端应用程序到达 Firestore 后端。 Try to execute it under different Networks and using different Devices.尝试在不同的网络下使用不同的设备执行它。
These Github Issue1 and Stackoverflow Links2 & 3 specify custom configurations for your Cloud Firestore instance and additional checks at Client network which could possibly help to avoid such issues.这些Github Issue1 和Stackoverflow Links2 & 3为您的 Cloud Firestore 实例指定自定义配置,并在客户端网络上进行额外检查,这可能有助于避免此类问题。 I would suggest you check with these links 1 , 2 & 3 as there are alternate solutions available.我建议您检查这些链接1 、 2和3 ,因为有可用的替代解决方案。
I had credentials setup in.env file which did show up as appropriate variables.我在 .env 文件中设置了凭据,它确实显示为适当的变量。 However, What worked for me was putting the credentials in a .js
file and use them from there.但是,对我有用的是将凭据放在.js
文件中并从那里使用它们。 Also, please do not forget to add the credentials file in .gitignore
另外,请不要忘记在.gitignore
中添加凭据文件
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.