I\'m looking to use an environment variable inside of the config.json file of my project using sequelize. I\'m using dotenv to set environment variables locally. My config.json
I worked on this for quite a bit. I do not know why Sequelize does not use production when it is literally in the environment if you run heroku run bash
. I was able to get it working by modifying the Sequelize object depending on the JAWSDB_URL
, not the NODE_ENV
.
require("dotenv").config();
const express = require("express")
const app = express();
let seq;
//express app configuration
if (process.env.JAWSDB_URL) {
console.log("There is a JAWS DB URL")
seq = new Sequelize(process.env.JAWSDB_URL)
}
else {
seq = require("./models").sequelize
}
seq.sync().then(() => {
app.listen(PORT, () => console.log('server started on port ' + PORT));
})