It states here that it's not a good practice to connect to a heroku db using a URL like this:
postgres://$user:$pass@$db_host.com:5432/$db_name
But you should rather "fetch the database URL config var from the corresponding Heroku app when your application starts" like this:
DATABASE_URL=$(heroku config:get DATABASE_URL -a your-app) your_process
I want to connect to a heroku db from an external (outside heroku) node server using sequelize. How should I do that?
const db = new Sequelize(DATABASE_URL, {
logging: false,
pool: {
max: 15,
min: 5,
idle: 10000,
acquire: 10000,
},
dialectOptions: {
ssl: {
require: true,
},
},
ssl: true,
});