Matt Wlazlo
Matt Wlazlo

Reputation: 357

Publishing Firestore rules: An unknown error occurred

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.

enter image description here

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

Answers (6)

If that doesn't work, try:

  1. Turn off all extensions in your browser.
  2. Save the rule
  3. Turn on extensions again

Upvotes: 0

Little_bugfixer
Little_bugfixer

Reputation: 50

Simply opening Firebase storage console on incognito and changing rules then, helped for me.

Upvotes: 0

Trystan Rivers
Trystan Rivers

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

Adnan Rruka
Adnan Rruka

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

Yovan
Yovan

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:

  1. npm install -g firebase-tools
  2. firebase login // finish the login procedure

// Set up Firestore in your project directory, creates a .rules file

  1. firebase init firestore

//Update the firestore.rules file that you can find in the root of the directory.

// Save and deploy your .rules file

  1. firebase deploy --only firestore:rules

Upvotes: 1

Meyer Frenchel
Meyer Frenchel

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

Related Questions