3

The ISR pages I have in my web application does not seem to be rendering because it says firebase permissions are insufficient however when I test those permissions, it works absolutely fine. I do not know what the issue is here.

Here are my firestore rules:

rules_version = '2';
service cloud.firestore {
  match /databases/{database}/documents {
    match /blogs/{blog} {
      allow read, get;
      allow write, update, create, delete: if (request.auth.uid == "R3tc0RKCDgX8yhaHS5c0Ej3IXxF3");
    }
    match /forum/{forum} {
      allow read, get;
      allow write, create, update, delete: if (request.auth.uid == "R3tc0RKCDgX8yhaHS5c0Ej3IXxF3");
    }
    match /forum/{forum}/messages/{messages} {
        allow read, get;
      allow write, create, update, delete: if (request.auth.uid != null);
    }
    match /chats/{room} {
        allow write, read, get, create, update, delete: if request.auth.uid == get(/databases/$(database)/documents/chats/$(room)).data.uid[0] || request.auth.uid == get(/databases/$(database)/documents/chats/$(room)).data.uid[1];
    }
    match /chats/{room}/messages/{messages} {
        allow write, read, get, create, update, delete: if request.auth.uid == get(/databases/$(database)/documents/chats/$(room)).data.uid[0] || request.auth.uid == get(/databases/$(database)/documents/chats/$(room)).data.uid[1];
    }
  }
}

and here is the getStaticPaths function for one of my ISR pages

export async function getStaticPaths() {
  let array = [];

  await getDocs(collection(firestore, "forum")).then((res) => {
    array = res.docs.map((data) => {
      const { id } = data.data();

      return {
        params: { question: id },
      };
    });
  });

  return {
    paths: array,
    fallback: "blocking",
  };
}

The firebase rules playground works absolutely fine and data is also fetched fine when done with Server Side Rendering but it fails when it comes to Incremental Static Regeneration of NEXT JS. Your help is highly appreciated.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
  • Have you validated your rules at [simulator](https://firebase.google.com/docs/rules/simulator)? – Sathi Aiswarya Jul 20 '22 at 11:52
  • yes i validated it. I could not find anything so I just made the chat rooms information available to the public not the actual chat rooms. I dont know whether it is safe or not now. (information includes IDs that are to be validated to allow access into the room) – Ibraheem Haseeb Jul 22 '22 at 12:16
  • edit your question with the exact error you are getting from firebase.Can you reproduce the issue without NEXT JS?When accessing "chat" where there are not restrictions on (read write get etc) does the issue still occur? – Sathi Aiswarya Jul 28 '22 at 07:44

0 Answers0