简体   繁体   English

错误:从硬编码数据更改为 process.env 后无法到达 Cloud Firestore 后端

[英]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.我建议您检查这些链接123 ,因为有可用的替代解决方案。

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.

相关问题 Firestore 错误:Firestore (9.1.0):无法访问 Cloud Firestore 后端 - Firestore errors: Firestore (9.1.0): Could not reach Cloud Firestore backend 为什么我收到 Expo Firestore 错误:无法到达 Cloud Firestore 后端。 后端没有在 10 秒内响应? - Why I am getting Expo Firestore error: Could not reach Cloud Firestore backend. Backend didn't respond within 10 seconds? 无法使用 Node.js 在 CloudRun 上访问 Cloud Firestore 后端 - Could not reach Cloud Firestore backend on CloudRun with Node.js Flutter -Firebase/FireStore - 无法访问 Cloud Firestore 后端。 后端在 10 秒内没有响应 - Flutter -Firebase/FireStore - Could not reach Cloud Firestore backend. Backend didn't respond within 10 seconds React Native Expo Firebase Firestore (9.9.3):无法访问 Cloud Firestore 后端 - React Native Expo Firebase Firestore (9.9.3): Could not reach Cloud Firestore backend 无法访问 Cloud Firestore 后端。 后端在 10 秒内没有响应 - Flutter Android Studio - Could not reach Cloud Firestore backend. Backend didn't respond within 10 seconds - Flutter Android Studio 在 Vue 和 Vite 中使用 process.env 时出错 - Error when I use process.env with Vue and Vite Firebase 机密未在 process.env 中定义 - Firebase secrets not defined in process.env 更改现有云 Firestore 集合中的数据 model? - Changing data model in existing cloud firestore collection? 使用 Firebase 云从 Cloud Firestore 读取数据 function - Read data from Cloud firestore with Firebase cloud function
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM