Firebase chat app setValue failed error with a public database?

馋奶兔 提交于 2019-11-26 02:16:49

Your code is using the Firebase Realtime Database, but you're changing the security rules for Cloud Firestore. While both databases are part of Firebase, they are completely different and the server-side security rules for one, don't apply to the other.

When you go the database panel in the Firebase console, you most likely end up in the Cloud Firestore rules:

If you are on the Cloud Firestore rules in the Firebase console, you can change to the Realtime Database rules by clicking Cloud Firestore BETA at the top, and then selecting Realtime Database from the list.

You can also directly go to the security rules for the Realtime Database, by clicking this link.

The security rules for the realtime database that match what you have are:

{
  "rules": {
    ".read": "auth.uid !== null",
    ".write": "auth.uid !== null"
  }
}

This will grant any authenticated user full read and write access to the entire database. Read my answer to this question on more on the security/risk trade-off for such rules: Firebase email saying my realtime database has insecure rules.

change this

request.auth.uid != null

to

request.auth.uid == null

or defined a proper auth mechanism before starting the conversation where user defined by userID

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!