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;