.Environment variables don't work in Vue.js

Viewed 340

I have .env file in the root of my project in Vue3. In the components folder, I have Card.vue and this code

console.log(process.env.FOO)

But in browser, it shows undefined.

2 Answers

Variables must start with VUE_APP, hence

`VUE_APP_FOO`

Having a similar problem here. I'm usnig VUE_APP_FOO to set the variable in .env but it's still undefined when console.log(process.env.VUE_APP_FOO). Using Vue2 (Vue cli 4.5.11)

Related