BuidlGuidl / grants.buidlguidl.com

https://grants-bg.vercel.app
MIT License
3 stars 3 forks source link

Firebase (firestore connection) #9

Closed carletex closed 9 months ago

carletex commented 9 months ago

Update: was getting an error (see below) but fixed it by downgrading to 11.x

The emulator works fine, but I'm not able to connect to it from the code (using something similar from what we have a bgv3). I'm getting:

Error: Could not load the default credentials. Browse to https://cloud.google.com/docs/authentication/getting-started for more information.

It shouldn't happen since it's an emulator connection. Tried with the env vars too:

FIREBASE_AUTH_EMULATOR_HOST=127.0.0.1:8080
FIREBASE_EMULATOR_HOST=127.0.0.1:8080
FIRESTORE_EMULATOR_HOST=127.0.0.1:8080
FIRESTORE_AUTH_EMULATOR_HOST=127.0.0.1:8080

We might leave this for a future PR (to not spend too much time on it... since we can use a "live" firestore instance)

Fixes #3

carletex commented 9 months ago

Had to downgrade firebase-admin to 11.x, because I couldn't make it work with the firebase local emulator (see OG comment). Will open an issue there.

11.x works for me!

carletex commented 9 months ago

lol, the error I was documenting here (with the emulator) might have been fixed just 15 min ago

https://github.com/googleapis/google-auth-library-nodejs/issues/1747

But it might need to be propagated to the @google-cloud/storage package (which is the one that firebase-admin uses)

image

I think we can keep 11.x

carletex commented 9 months ago

Hey @technophile-04

I have experienced that before, and in my case was because of the projectId. On firestoreDB we are doing:

    initializeApp({
      projectId: "buidlguidl-v3",
    });

That needs to match with the local instance project Id. I think you had to specify a project ID when running the emulators the first time, right? You can also do --project <projectId> when initializing the emulators.

Let me know if that helps!

technophile-04 commented 9 months ago

Ohhh yeah actually there was difference in projectId and it seems that when using --import flag it does update the database but when I tried without --import everything was in sync ! Thanks 🙌