[英]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.