fix: Allow disabling SSL for Postgres connection with standard PGSSLMODE env
closes #1501
This commit is contained in:
@ -4,6 +4,7 @@ import Sequelize from "sequelize";
|
|||||||
import EncryptedField from "sequelize-encrypted";
|
import EncryptedField from "sequelize-encrypted";
|
||||||
|
|
||||||
const isProduction = process.env.NODE_ENV === "production";
|
const isProduction = process.env.NODE_ENV === "production";
|
||||||
|
const isSSLDisabled = process.env.PGSSLMODE === "disable";
|
||||||
|
|
||||||
export const encryptedFields = () =>
|
export const encryptedFields = () =>
|
||||||
EncryptedField(Sequelize, process.env.SECRET_KEY);
|
EncryptedField(Sequelize, process.env.SECRET_KEY);
|
||||||
@ -15,11 +16,12 @@ export const sequelize = new Sequelize(process.env.DATABASE_URL, {
|
|||||||
logging: debug("sql"),
|
logging: debug("sql"),
|
||||||
typeValidation: true,
|
typeValidation: true,
|
||||||
dialectOptions: {
|
dialectOptions: {
|
||||||
ssl: isProduction
|
ssl:
|
||||||
? {
|
isProduction && !isSSLDisabled
|
||||||
// Ref.: https://github.com/brianc/node-postgres/issues/2009
|
? {
|
||||||
rejectUnauthorized: false,
|
// Ref.: https://github.com/brianc/node-postgres/issues/2009
|
||||||
}
|
rejectUnauthorized: false,
|
||||||
: false,
|
}
|
||||||
|
: false,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user