Deploying a PostgreSQL database with HEROKU and getting SSL off error
Posted by Ninja Space Content on Thursday, February 18, 2021 Under: postgres
In : postgres
Tags: postgres deploying with seed data issue ssl
const { Client } = require('pg');
const client = new Client({
connectionString: process.env.DATABASE_URL,
ssl: {
rejectUnauthorized: false
}
});
client.connect();
Note that this is the code you will need to deploy with for Heroku only. For development, make sure the connection string is set locally. It will cause errors when you use the model code above for developing but don't worry, use the snippet for Heroku deployment.
The key thing is for deployment, you need to add the ssl: {rejectUnauthorized: false} for Heroku.
After I've deployed on Heroku, I ran my seed data and saw that my seed data was successfully shown on my deployed link. I commented out the model snippet and then, just have my connection string to my localhost again while I'm developing. I hope this helps you!
In : postgres
Ninja Space Content |
California |
![]() |