Skip to content

Commit c446a91

Browse files
committed
fix: Restore Postgres SSL support on Heroku
brianc/node-postgres#2009
1 parent ec55299 commit c446a91

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

server/config/database.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99
},
1010
"production": {
1111
"use_env_variable": "DATABASE_URL",
12-
"dialect": "postgres"
12+
"dialect": "postgres",
13+
"dialectOptions": {
14+
"ssl": {
15+
"rejectUnauthorized": false
16+
}
17+
}
1318
}
1419
}

server/sequelize.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,23 @@ import debug from "debug";
33
import Sequelize from "sequelize";
44
import EncryptedField from "sequelize-encrypted";
55

6+
const isProduction = process.env.NODE_ENV === "production";
7+
68
export const encryptedFields = () =>
79
EncryptedField(Sequelize, process.env.SECRET_KEY);
810

911
export const DataTypes = Sequelize;
1012
export const Op = Sequelize.Op;
1113

1214
export const sequelize = new Sequelize(process.env.DATABASE_URL, {
13-
// logging: console.log,
1415
logging: debug("sql"),
1516
typeValidation: true,
17+
dialectOptions: {
18+
ssl: isProduction
19+
? {
20+
// Ref.: https://github.com/brianc/node-postgres/issues/2009
21+
rejectUnauthorized: false,
22+
}
23+
: false,
24+
},
1625
});

0 commit comments

Comments
 (0)