DEV Community

Discussion on: How to Use Environment Variables in Vue.js

Collapse
 
doannucphys profile image
doannucphys • Edited

if i have a variable VUE_APP_MY_SECRET in .env file, then when i deploy vue-cli app, can user read process.env.VUE_APP_MY_SECRET from chrome browser console by running process.env.VUE_APP_MY_SECRET from console? how to protect this value from user ?

Collapse
 
turbopasi profile image
Pascal Lamers • Edited

You shouldn't include any secrets in your frontend/clientside code. From the official docs:

"WARNING
Do not store any secrets (such as private API keys) in your app! Environment variables are embedded into the build, meaning anyone can view them by inspecting your app's files."

During the build process all environment variables will simply be swapped with plain text. So in frontend only use env variables for non-secrets.