Home > database >  Firebase error saving rules - Line 10: String can't contain ".", "#", "
Firebase error saving rules - Line 10: String can't contain ".", "#", "

Time:01-30

I follow the guide (https://firebase.google.com/docs/rules/insecure-rules#database) and try to change the rules. But I have an error

Can anyone expalain what is wrong?

CodePudding user response:

The error you are receiving is due to some inconsistency in the documentation - The / character is disallowed. I've managed to publish a similar set of rules by changing it to nested paths.

{
  "rules": {
    "Users": {
      "$uid": { 
        ".read": true,
        ".write": "auth.uid == $uid"
      }
    }
  }
}

Note: I'm assuming you are using Firebase Realtime Database. If you are using Firestore, use request.auth.id instead

CodePudding user response:

I wrote to support and they told me there was a bug in their documentation. And the correct answer is:

{
  "rules": {
    "Users" :{
      "$uid": {
        ".read": true,
        ".write": "auth.uid == $uid"
      }
    }
  }
}
  •  Tags:  
  • Related