[Vuejs]-Vue.js, GitHub, Heroku – How to dynamically, securely set environment vars?

0👍

You can use the library dotenv to load your enviornment variables from a single .env file.

You can define your enviornemnt vars in a file named .env

VUE_APP_SOME_VAR=someVARvalue
VUE_APP_SOME_OTHER_VAR=someOTHERVARValue

Then you can load these vars from .env in any file like this

require('dotenv').config()

//...
//...

process.env.VUE_APP_SOME_VAR

//...
//...

You can learn more here

Additionally, you should not commit your .env file to your version control software as it might contain sensitive authentication keys. You can configure Heroku to use the same enviornment variables by setting Configuration Variables in the apps settings page.

Leave a comment