[Vuejs]-Vue.js: To Get Environment Variables in js File

5👍

Just restart your server as newly created env variables are not available only after hot-reload you have to rebuild your application (restart your server). For reference you can look here

1👍

No need to install “dotenv” simply place .env file in the root of your project (at the same level of your package.json file) and Vue CLI will handle the reset. Side note; as of Vue CLI 3 only variables that start with VUE_APP_ will be loaded. make sure also to rerun npm run serve again to restart your server.

for more details: visit docs

Leave a comment