(node.js) how to use environment variables in JSON file

JSON does not have notion of environment variables. What you can do though is to declare your configuration file as node.js module and then you will be able to use your environment variables as follows:

module.exports = {
  s3: {
    key: process.env.AWS_ACCESS_KEY_ID,
    secret: process.env.AWS_SECRET_ACCESS_KEY,
    bucket: process.env.S3_MLL_BUCKET_NAME,
    destination: "/backups/database",
    encrypt: false,
    region: process.env.AWS_REGION
  }
};

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)