如何获取/设置Firebase云功能v1环境变量 [英] how to get/set firebase cloud functions v1 environment variables

查看:36
本文介绍了如何获取/设置Firebase云功能v1环境变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过使用 functions.config()命令以旧方式使用Cloud Functions软件包中的环境变量,但是由于我已更新至v1.0.2,因此即使通过<像文档中指示的那样执行code> JSON.parse(process.env.FIREBASE_CONFIG),但是我找不到如何设置或获取其他信息.该命令仅提供有关项目的信息,而没有提供我使用旧方法设置的信息.如何使用新方法获取/设置此信息?
预先感谢.

I was using the environment variables from Cloud Functions package the old way by using the functions.config() command, but since I updated to v1.0.2 I cannot use the env variables even through JSON.parse(process.env.FIREBASE_CONFIG) like the documentation tells to do, and I couldn't find how to set or get other information. This command only gives me information about the project but not the information I have set using the old approach. How can I get/set this information using the new approach?
Thanks in advance.

推荐答案

The documentation for the environment changes in 1.0 can be a little confusing. functions.config() isn't going away - you still use that to access environment variables that you set using the Firebase CLI with firebase functions:config:set. The things that changed with respect to configuration are the following:

  • functions.config().firebase 不再用于项目配置.该信息现在以 process.env.FIREBASE_CONFIG 的形式存储在流程环境中.
  • 您现在可以将不带任何参数的Admin SDK初始化为 admin.initializeApp().配置将从Cloud Functions运行时自动获取.
  • functions.config().firebase is no longer used for project configuration. That information is now stored in the process environment as process.env.FIREBASE_CONFIG.
  • You can now initialize the Admin SDK with no arguments as admin.initializeApp(). The configuration will be picked up from the Cloud Functions runtime automatically.

这篇关于如何获取/设置Firebase云功能v1环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆