fix: allow non SSL connections to be handled gracefully

pull/409/head
nilsorbat 3 years ago
parent 5b47c7cef6
commit 136ba2f48f
No known key found for this signature in database
GPG Key ID: 0F9E4305534A2380

@ -14,6 +14,9 @@ SECRET_KEY=notsecretkey
# have to use environment variables in order to pass the desired values, e.g. # have to use environment variables in order to pass the desired values, e.g.
# PGSSLMODE=<value> # PGSSLMODE=<value>
# Configure knex to accept SSL Certificates
# REJECT_UNAUTHORIZED_SSL_CERTIFICATE=false
## Do not edit this ## Do not edit this
TZ=UTC TZ=UTC

@ -6,13 +6,21 @@ dotenv.config({
path: path.resolve(__dirname, '../.env'), path: path.resolve(__dirname, '../.env'),
}); });
function buildSSLConfig() {
if (process.env.REJECT_UNAUTHORIZED_SSL_CERTIFICATE) {
return {
rejectUnauthorized: false,
};
}
return false;
}
module.exports = { module.exports = {
client: 'pg', client: 'pg',
connection: { connection: {
connectionString: process.env.DATABASE_URL, connectionString: process.env.DATABASE_URL,
ssl: { ssl: buildSSLConfig(),
rejectUnauthorized: false,
},
}, },
migrations: { migrations: {
tableName: 'migration', tableName: 'migration',

Loading…
Cancel
Save