Search code examples
javascriptnode.jsfirebasegoogle-cloud-functions

How to get Firebase Project Name or ID from Cloud Function


I am using Cloud Functions and want to get the project name from within one of my Javascript server files. I know that value is stored in the .firebaserc, but I don't think that file is available on the server, right? I want to do something like this:

const functions = require('firebase-functions');
const admin = require('firebase-admin');

admin.getProjectName();  // or getProjectID()

or

functions.getProjectName(); 

Solution

  • Thank you @Frank. The answer is: process.env.GCLOUD_PROJECT.
    I'm not sure where the variable process comes from, but this does work to get the project name.