Using Firebase and get the following error in the console?
Uncaught Error in onSnapshot: FirebaseError: Missing or insufficient permissions.<br>at new FirestoreError (index.cjs.js:x)
How to fix the Missing or Insufficient Permissions Error
Option 1: Change rules (Recommended)
- Login to Firebase
- Go to
Database
->Rules
Change:
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if false;
}
}
}
to:
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if request.auth != null;
}
}
}
Option 2: Override Authorization / Disable Security
- Login to Firebase
- Go to
Database
->Rules
- Change
allow read, write
fromfalse
totrue
[for dev] - Change
allow read, write
fromfalse
torequest.auth != null
[for prod]