Reputation: 357
On a newly created project, I cannot publish any changes to the Firebase rules. Even simple changes like adding a newline to the end of the file or adding a space.
I feel like this may be a bug in Firestore but thought I'd ask here first...
Error saving rules –An unknown error occurred
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if false;
}
}
}
Upvotes: 14
Views: 7214
Reputation: 1
If that doesn't work, try:
Upvotes: 0
Reputation: 50
Simply opening Firebase storage console on incognito and changing rules then, helped for me.
Upvotes: 0
Reputation: 829
I found that the Allow CORS: Access-Control-Allow-origin
Chrome extension was the cause of this error for me. Disabling the extension fixed the error.
Upvotes: 70
Reputation: 1
The only way i got it to work is through CLI, Init it, chose the existring project you have and change the rules in the .rules file, then deploy them.
Upvotes: 0
Reputation: 11
Had the same issue all of a sudden, "an unknown error occurred" for the Firestore security rules. Fixed it by updating it through the Firebase CLI.
So, in the terminal do the following steps:
// Set up Firestore in your project directory, creates a .rules file
//Update the firestore.rules file that you can find in the root of the directory.
// Save and deploy your .rules file
Upvotes: 1
Reputation: 41
Install Firebase CLI in your command prompt, login in the firebase CLI, then open the .rules file with your editor(vscode, atom) and replace it with :
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if true;
}
}
}
then deploy to firebase with from your command prompt with this command
firebase deploy --only firestore:rules
Upvotes: 4