简体   繁体   English

Firebase 函数环境变量不起作用

[英]Firebase functions environment variables not working

I have test.env file in my functions folder.我的函数文件夹中有test.env文件。

test.env测试环境

 TEST="TEST NAME"

And in my functions I have:在我的职能中,我有:

app.get("/testvars", (req, res) => {
    console.log("ENV", process.env.TEST);
});

I then run firebase serve , which logs ENV undefined when invoked然后我运行firebase serve ,它在调用时记录ENV undefined

Why is this not working?为什么这不起作用?

And I am using firebase-functions 3.23.0 with 11.8.0 firebase cli我正在使用带有11.8.0 firebase cli 的 firebase-functions 3.23.0

Rename your file from test.env to just .env (starting with a dot).将文件从test.env重命名为.env (以点开头)。

https://firebase.google.com/docs/functions/config-env#env-variables https://firebase.google.com/docs/functions/config-env#env-variables

If you are having a project alias named test then you should put the project id/alias after .env ( .env.test ).如果您有一个名为test的项目别名,那么您应该将项目 ID/别名放在.env ( .env.test ) 之后。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Firebase 函数环境变量 - Firebase Functions environment variables Firebase 使用环境变量托管? - Firebase Hosting with Environment Variables? Nuxt + Firebase - 正确处理环境变量的方法 - Nuxt + Firebase - Correct way to handle environment variables 环境变量在反应 firebase 配置文件中不起作用 - environment variable not working in react firebase config file Firebase 凭证作为 Python 环境变量:无法反序列化关键数据 - Firebase credentials as Python environment variables: Could not deserialize key data Flutter - Firebase 区域不工作的可调用函数 - Flutter - Firebase callable functions with region not working 有没有办法在 Amplify 的 lambda 函数之间共享环境变量和秘密? - Is there a way to share environment variables and secrets among lambda functions in Amplify? 在Golang中只用环境变量初始化Firebase Admin SDK - Initialize Firebase Admin SDK with only environment variables in Golang Firebase主机如何通过环境变量提供预览通道? - How to provide preview channels on Firebase hosting with environment variables? 在 React Boilerplate 中使用 firebase-messaging-sw.js 中的环境变量 - Utilizing environment variables in firebase-messaging-sw.js in React Boilerplate
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM