0

I have two Firebase projects, and two service-accounts, so I am using (.env.dev, .env.prod)

I tried everything to import the service account path from .env.dev and .env.prod but nothing worked, I always have to comment and uncomment when deploying to a specific project, and it's painful and error-prone.

Need help !

// PROD
admin.initializeApp({
  credential: admin.credential.cert("./src/service-account.json"),
  storageBucket: "prod.storage.com"
});

// DEV
admin.initializeApp({
  credential: admin.credential.cert("./src/service-account-dev.json"),
  storageBucket: "dev.storage.com"
});
Astrocode
  • 39
  • 2
  • 10
  • Please have a look at this stackoverflow [link1](https://stackoverflow.com/questions/54571158/deploying-different-service-account-credentials-json-file-to-different-cloud-fun) & [link2](https://stackoverflow.com/questions/43655441/firebase-configuration-for-multiple-projects-environments) – Sathi Aiswarya Mar 19 '23 at 09:39
  • 1
    You shouldn't use service account key file. And your issue will be solved! – guillaume blaquiere Mar 19 '23 at 15:48
  • Your function runs as the service account specified by the `--service-account=` flag when deploying the function. You don't need to use a service account key when it is deployed in GCP, just make sure it deploys as the required service account. – anothermh Mar 21 '23 at 22:25

0 Answers0