nabisorry
nabisorry

Reputation: 3

firebase Error : Missing or insufficient permissions with react js

When using firebase An error occurs as below.

redux-firestore listener error: FirebaseError: Missing or insufficient permissions.

current firestore rule

service cloud.firestore {
  match /databases/{database}/documents {
    match /{document=**} {
      allow read, write: if request.auth.uid != null;
    }
  }
}

If change the firestore rule, it will work.

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

What's the problem?

Upvotes: 0

Views: 1701

Answers (1)

Doug Stevenson
Doug Stevenson

Reputation: 317372

Your first security rule requires that a user is signed in with Firebase Auth. If that's not the case, the error makes sense.

Your second rule opens up queries to anyone on the internet. In fact, it allows all reads and writes, which is a fairly significant security problem.

I strongly suggest that you learn how security rules work, and if security is a priority, to also use Firebase Authentication so you can determine who can read and write your database.

Upvotes: 3

Related Questions