Skip to content

Instantly share code, notes, and snippets.

@onosendi
Created November 9, 2023 16:14
Show Gist options
  • Save onosendi/1c535f4af64078d1e54e65cbcf214f16 to your computer and use it in GitHub Desktop.
Save onosendi/1c535f4af64078d1e54e65cbcf214f16 to your computer and use it in GitHub Desktop.
JWT_SECRET=dev secret
JWT_SECRET=prod secret
.env.production
const dotenv = require('dotenv');
const env = process.env.NODE_ENV === 'production'
? '.env.production'
: '.env.local';
dotenv.config({ path: env })
const config = {
jwt_secret: process.env.JWT_SECRET,
}
module.exports = config;
const config = require('./config');
console.log(config);
{
"scripts": {
"start": "NODE_ENV=production node .",
"dev": "NODE_ENV=development node ."
},
"dependencies": {
"dotenv": "^16.3.1"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment