My Firestore read requests are getting errored out. I believe that some sort of incorrect blacklisting has happened.
Environment: development
Purpose: To get a list of all documents in my Firestore collection named "auth"
Firestore rules:
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if request.auth != null;
}
}
}
Code:
Solved! Go to Solution.
Based on inputs from the community, I realized that my rules were not permitting requests from unauthenticated users in the new login/registration pages which was exactly where the issue occurred.
I've updated my rules to,
rules_version = '2'; service cloud.firestore { match /databases/{database}/documents { match /auth/{document=**} { allow read, write: if true; } } }
Could you please share the error message ? It might help diagnose the cause.
To list all documents in a collection:
const citiesRef = db.collection('cities');
const snapshot = await citiesRef.get();
snapshot.forEach(doc => {
console.log(doc.id, '=>', doc.data());
});
Hi Julien, this is my error message,
index-00398238.js:1 FirebaseError: Missing or insufficient permissions.
But I get a 200 response for my Firebase Firestore requests.
Also, I get the same error message irrespective of whether the document that I'm looking up is present or not.
Hope this is sufficient information.
Based on inputs from the community, I realized that my rules were not permitting requests from unauthenticated users in the new login/registration pages which was exactly where the issue occurred.
I've updated my rules to,
rules_version = '2'; service cloud.firestore { match /databases/{database}/documents { match /auth/{document=**} { allow read, write: if true; } } }
I tried to do that. But It's not changed on the remote. It still keep the default value.
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write: if false;
}
}
}
Can you provide some screenshots for context? The configuration seems fine, are there any error messages that you see?
Yes. I send some pictures below (successfully message, my rules, result on GG firestore).
This is my rules