Using the --debug argument I've found out that if there isn't a database.rules.json file in the init directory, it will automatically copy what is online in the project. But here's the problem: If the database hast been initialized yet, it will return invalid json (since the rules haven't been setup yet).
So here's how to fix:
- Create your own
database.rules.json file in your project directory and configure it with valid json.
{
"rules": {
".read": true,
".write": false
}
}
- When you run firebase init and get to the part where it asks you
What file should be used for Realtime Database Security Rules? use the already created file (so usually just 'database.rules.json').
- If you pointed to the correct file it will ask you
File database.rules.json already exists. Do you want to overwrite it with the Realtime Database Security Rules for insektenhotel-default-rtdb f rom the Firebase console? (This is automatically yes if the files doesn't exist, causing the problem). Say No.
It should work now.
database.rules.jsonlook like?database.rules, and remove.jsonextension// These rules grant access to a node matching the authenticated // user's ID from the Firebase auth tokenin your FIrebase Realtime Database rules, apparently Comments are not permitted in JSON.