How to set and use env variables on the server and in various languages.
The best to set and use env variables to be used within a node app is with the use of .env package (which cab be found in other languages as well).
Firstly install the package:
npm i dotenv --save
To set the variables create a .env
file in the root of your project. Example of .env file:
VARIABLE_NAME=value_here
To use the variables, all you have to do is:
process.env.VARIABLE_NAME