reference used firebase project in firebase function

Viewed 31

I have a firebase functions project, and I switch between projects (dev & prod) using the firebase cli command firebase use [project]

How can I figure out in my functions which project is used? I thougth it would be in .firebaserc, but that is not being updated by the cli command...

Thanks for your advice!

1 Answers

Inside the running function, you should be able to parse out project from the FIREBASE_CONFIG environment variable:

const {projectId} = JSON.parse(process.env.FIREBASE_CONFIG);
Related