I can’t write data to my firebase

Asked

Viewed 305 times

-1

Error: Uncaught (in promise): Error: PERMISSION_DENIED: Permission denied
Error: PERMISSION_DENIED: Permission denied

Setting up my firebase looks like this:

service cloud.firestore {
  match /databases/{database}/documents {
    match /{document=**} {
      allow read, write: if 'true';
    }
  }
}

Before it was like this in the original configuration:

service cloud.firestore {
  match /databases/{database}/documents {
    match /{document=**} {
      allow read, write;
     }
   }
 }
  • And why are you doing allow read, write: if 'true'; instead of leaving as it was before aallow read, write;? This command if 'true'; is not run by the way

2 answers

0


It turns out you are changing the data in the wrong location.

In the Firebase there is a new option called Cloud Firestore, which is selected by default (see image below), but That’s not where you should change it and yes in the Realtime Database

inserir a descrição da imagem aqui

When selecting the option Realtime Database>Rules, change the settings to the following:

{
  "rules": 
{
    ".read": true,
    ".write": true
  }
}

inserir a descrição da imagem aqui

0

At a glance here... The firebase site has great documentation, read it carefully that you will be able to do what you want.

According to this link you have to do so

service cloud.firestore {
  match /databases/{database}/documents {
    match /{document=**} {
      allow read, write: if true;
    }
  }
}

Without the quotes you put on if 'true';

And from what I understand you want to free access for everyone, so in this case leave as it already comes by default

service cloud.firestore {
  match /databases/{database}/documents {
    match /{document=**} {
      allow read, write;
    }
  }
}
  • So when I did the test, I also tried in the default configuration and gave error anyway, or maybe the error happens because there is no user logged in

  • Go to Authentication > Login method and enabled Anonymous mode and see if it resolves. And also try the following: Go to Database > Cloud Firestore > Rules and use the simulator you have there

Browser other questions tagged

You are not signed in. Login or sign up in order to post.