0

I am working on a web app and I faced to new problem on localhost which is FirebaseError: Missing or insufficient permissions but the live version of app that use same firebase firestore works perfectly.

this is my firebase rules:

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

I must mention it that there is no problem with usage limit. here you can see one block of code which trow the error I mentioned:

    async getUserData(userUid) {
      const q = query(
        collection(db, "userProfile"),
        where("userUid", "==", userUid)
      );
      const querySnapshot = await getDocs(q);
      querySnapshot.forEach(doc => {
        this.provider.unshift(doc.data().serviceAddress);
      });
    },
Pooya Panahandeh
  • 578
  • 7
  • 21
  • There's not much we can do without detailed instructions on how you reproduce this error, along with the app code that makes the query. Your debugging information should illustrate that there is a user signed in, as your rules require. – Doug Stevenson May 22 '22 at 15:25
  • Check this [stackoverflow](https://stackoverflow.com/questions/46590155/firestore-permission-denied-missing-or-insufficient-permissions) and [github](https://github.com/actions-on-google/smart-home-nodejs/issues/369) – Tio May 22 '22 at 15:36
  • @DougStevenson I update the question and add more details to it. – Pooya Panahandeh May 22 '22 at 16:11
  • @Nsyn I checked those answers, it seems that I need different solution for the same error. – Pooya Panahandeh May 22 '22 at 16:12
  • 1
    Now add some logging that conclusively proves that there is a user signed in at the time of the query. The passing of a variable called userUid doesn't necessarily mean anything. – Doug Stevenson May 22 '22 at 16:53

1 Answers1

0

Please check if you have added localhost in Authorized Domains.

Log in Firebase Console, in Authentication / Authorized Domains, make sure you see something like - enter image description here

ch_g
  • 1,394
  • 8
  • 12
  • localhost is Authorized but still have same issue – Pooya Panahandeh May 22 '22 at 16:09
  • @PooyaPanahandeh did you get any solution? I am facing similar issue. Firebase authentication works but when I get data from Firestore it throws FirebaseError: Missing or insufficient permissions. – vinoth87 Oct 03 '22 at 12:28
  • Have you tried to work with the local emulator? Easier to see the request to the database and check the rules. – matsmats Jan 04 '23 at 07:33