Sails.js Environment Config Variables
So Sails.js way of handling environment variables is horrifying.
What we really need is a place to store all of our config variables regardless if we are in a development, testing, or production environment. The answer is simple: use dotenv. This will load a
.env file or look for environment variables on the machine.
Start by pulling it into the Sails.js project and following the dotenv docs:
Then require dotenv in
app.js and load the
.env and put some vars in it:
Now you can access those environment variables anywhere in the app (probably in some