Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change admin.initializeApp when deploying different environments

I am using Firebase Functions. I have 2 environments: one for dev and other for staging.

My question is how can I change admin.initializeApp config when deploying to each environment because the databaseURL is changing:

admin.initializeApp({
  credential: [...],
  databaseURL: "someurl"
});

Thanks!

like image 541
Vitaly Menchikovsky Avatar asked Sep 12 '25 09:09

Vitaly Menchikovsky


1 Answers

You do this just like you are using the Firebase Admin SDK in a regular node.js app. The setup instructions are here. There are also instructions in the Firebase console when you go to download the project's service account credentials.

When you download the service account key file, you can put it in your functions directory so it can be loaded with require() and passed to initializeApp.

like image 111
Doug Stevenson Avatar answered Sep 14 '25 00:09

Doug Stevenson