From 8ac2763dff5f2f98a90cd41e765ad606855c609a Mon Sep 17 00:00:00 2001 From: Matt Huntington Date: Thu, 4 Mar 2021 09:43:08 -0500 Subject: [PATCH] heroku pg update --- postgres.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/postgres.js b/postgres.js index c756e29..80dc94c 100644 --- a/postgres.js +++ b/postgres.js @@ -1,7 +1,16 @@ const Client = require('pg').Client -const client = new Client({ - connectionString: process.env.DATABASE_URL || 'postgresql://localhost:5432/contacts', -}) +const dbConfig = { + connectionString: 'postgresql://localhost:5432/contacts', +} + +if(process.env.DATABASE_URL){ + dbConfig.ssl = { rejectUnauthorized: false } + dbConfig.connectionString = process.env.DATABASE_URL + +} + +const client = new Client(dbConfig) + module.exports = client;