I've been trying to create a mostly public database with a few restrictions using database rules and hosting through CLI. I can access the database if I declare it open under rules, but if I remove the read/write from the top level and try to access it just one child "rules" I encounter a permissions error:
[2018-10-04T16:13:56.926Z] @firebase/database: FIREBASE WARNING: set at /2019/statistics/topTens/Strider Balance Bike/1 failed: permission_denied
Uncaught (in promise) Error: PERMISSION_DENIED: Permission denied
My database rules are:
{
"rules": {
"participants": {
"$pid": {
".read": true,
".write": true
}
},
"statistics": {
".read": true,
".write": true
},
"users": {
"$uid": {
".read": "$uid === auth.uid",
".write": "$uid === auth.uid"
}
}
}
}
When I try to write to statistics even though .read and .write are true, I get the above error. Does it have something to with the database defaulting to requiring authentication? I'm also using firebase hosting to host this. I've made sure that the database-rules.json file is configured the same way as the database rules within firebase as well. I've restarted the local server with firebase serve as well, no luck. What am I doing wrong here?