vuejs / vuefire

🔥 Firebase bindings for Vue.js
https://vuefire.vuejs.org
MIT License
3.82k stars 323 forks source link

GOOGLE_APPLICATION_CREDENTIAL alternative for monorepos #1462

Closed mklueh closed 7 months ago

mklueh commented 7 months ago

What problem is this solving

Hi there,

as it seems that declaring the service account the old way in nuxt.config.ts is gone

    admin: {
      serviceAccount: "serviceAccountKey.json"
    }

There needs to be a way to handle multiple such serviceAccountKeys for multiple applications within a monorepo.

I'm not sure if there is any alternative at all right now and if this might already possible, but I have at least not seen a way to specify the json file anymore.

Maybe it's this property now?

image

But it says "ID", which does not sound like the file to me.

Proposed solution

-

Describe alternatives you've considered

No response

posva commented 7 months ago

@mklueh Can you detail how do you handle things when you deploy to Firebase? Even if it's a mono repo, you should still be able to set different environment variables for each app

juane1000 commented 7 months ago

On a related note, can we also get a way to specify where "firebase.json" file is located so that the emulators get picked up? I also have a monorepo setup and can't get the Nuxt plugin to connect to them even with the flag set.

posva commented 7 months ago

Do you have an example that requires renaming the firebase.json file? Does that work with Firebase tools?

Subin-Qreative commented 7 months ago

in the documentation https://vuefire.vuejs.org/nuxt/environment-variables.html it says you can set it to the content of the file itself. can you please show me an example of this. I am trying to self host on my own server , it works in development mode but soon as I do a build it doesn't work. I belive the service-account is not being found.

Subin-Qreative commented 7 months ago

it seems if im hosting my server on google cloud and has same account associated with that server in firebase , but if my config is targeting another firebase account it gets overridden and uses the account on google cloud where the server is hosted instead.... so weird

EDIT , this was indeed the case . fixed by initializing using credential: cert({ ## })

juane1000 commented 7 months ago

Do you have an example that requires renaming the firebase.json file? Does that work with Firebase tools?

I use the default Firebase project structure where so that the directory looks something like this at the root:

The 'apps' directory has multiple SSR applications in some web framework or another served via firebase cloud functions using shared database resources. Due to this nesting I believe vuefire can't find the firebase.json config. The 'firebase.json' config lets you specify the directory that contains your build output so it's no problem deploying with this setup. The instructions for this were from Nuxt/Nitro documentation at: https://nitro.unjs.io/deploy/providers/firebase

That all works for me and I can successfully deploy/serve my app. It's only vuefire that doesn't work so I had to use raw fb SDK.

posva commented 7 months ago

I see, makes sense. Let’s add ann option. Feel free to submit a PR to accelerate things!

posva commented 7 months ago

Instead of adding an option to define the path of the firebase.json file, let's remove the need to read it altogether: #1429