如何从 Cloud Function 获取 Firebase 项目名称或 ID [英] How to get Firebase Project Name or ID from Cloud Function
本文介绍了如何从 Cloud Function 获取 Firebase 项目名称或 ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用 Cloud Functions 并希望从我的一个 Javascript 服务器文件中获取项目名称.我知道该值存储在 .firebaserc 中,但我认为该文件在服务器上不可用,对吗?我想做这样的事情:
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()
或
functions.getProjectName();
推荐答案
谢谢@Frank.答案是:process.env.GCLOUD_PROJECT
.
我不确定变量 process
来自哪里,但这确实可以获取项目名称.
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.
这篇关于如何从 Cloud Function 获取 Firebase 项目名称或 ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文