Is the following, the correct way to do this?
NOTE: The call to dotenv in config.local.js
config.js
module.exports = {
custom: {
myApiKey: process.env.MY_API_KEY
}
};
config.local.js
require('dotenv').config();
module.exports = {}
config.prod.js
module.exports = {}
app.js
const key = this.$app.$config.custom.myApiKey
.env
STAGE = "local"
MY_API_KEY = "KEY1"
When stage is ‘local’, the value from the .env file will be used. When the state is ‘prod’, the value from the lambda environment variable will be used.
Thanks,
Mark