Replies: 1 comment
-
|
It sounds like the REST API is working, but the Firestore client SDK is not successfully reaching the Firestore backend transport layer. A few things I would check:
For the modular web SDK, it should be initialized like this: import { initializeApp } from "firebase/app";
import { initializeFirestore } from "firebase/firestore";
const app = initializeApp(firebaseConfig);
export const db = initializeFirestore(app, {
experimentalAutoDetectLongPolling: true,
// or:
// experimentalForceLongPolling: true,
});If
In Chrome DevTools: Application → Storage → Clear site data
Look for requests to Firestore/WebChannel endpoints. If they are pending, blocked, cancelled, or failing, the issue is likely network transport related rather than Firestore rules.
import { doc, getDocFromServer } from "firebase/firestore";
const ref = doc(db, "collectionName", "documentId");
const snap = await getDocFromServer(ref);
console.log(snap.exists(), snap.data());
REST working can still happen if the client app is using a different If all of those are correct, I would suspect a browser/network transport issue with the Firestore SDK rather than security rules, because public rules and a working REST response usually point away from permissions. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Category: Google AI Studio / Firebase
I've been stuck on this for days. My Firestore database is reporting "offline" in my app, even though:
· The REST API works (I get a 200 response)
· Firestore API is enabled
· Security rules are public
· API key has no restrictions
· I added experimentalForceLongPolling: true
· Internet is fine (tested on different networks)
Yet my app still says: "Failed to get document because the client is offline"
Has anyone solved this? What am I missing?
Beta Was this translation helpful? Give feedback.
All reactions