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();
Using the Firebase console: Click settings Project settings. The project ID is displayed in the top pane. Using the Firebase CLI: Run firebase projects:list . The project ID is displayed along with all the Firebase projects associated with your account.
You can get project ID as const projectId = process. env. GCP_PROJECT .
You can just delete the current project, make a new project, download its google-services. json file and replace it with the current one in your app folder then finally you'll have to clean your project from Build -> CleanProject! That's it!
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.
Firebase admin SDK has access to that information for you.
const admin = require('firebase-admin'); const projectId = admin.instanceId().app.options.projectId
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With