diff --git a/server/core/db.js b/server/core/db.js index b729282a4c..d385102dd4 100644 --- a/server/core/db.js +++ b/server/core/db.js @@ -31,6 +31,7 @@ module.exports = { let dbClient = null let dbConfig = (!_.isEmpty(process.env.DATABASE_URL)) ? process.env.DATABASE_URL : { host: WIKI.config.db.host.toString(), + socketPath: WIKI.config.db.socketPath.toString(), user: WIKI.config.db.user.toString(), password: WIKI.config.db.pass.toString(), database: WIKI.config.db.db.toString(), @@ -91,6 +92,12 @@ module.exports = { dbConfig.ssl = sslOptions } + // Prune host and port if socketPath is configured + if (dbConfig.socketPath) { + const { host, port, ...prunedConfig} = dbConfig; + dbConfig = prunedConfig; + } + // Fix mysql boolean handling... dbConfig.typeCast = (field, next) => { if (field.type === 'TINY' && field.length === 1) {