简体   繁体   中英

Firebase functions environment variables not working

I have test.env file in my functions folder.

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

Why is this not working?

And I am using firebase-functions 3.23.0 with 11.8.0 firebase cli

Rename your file from test.env to just .env (starting with a dot).

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 ).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM