diff --git a/src/lib/coolify-db.ts b/src/lib/coolify-db.ts index ec4181f..3cdc362 100644 --- a/src/lib/coolify-db.ts +++ b/src/lib/coolify-db.ts @@ -6,10 +6,19 @@ const { Pool } = pg; let pool: pg.Pool | null = null; +function parseDbUrl(url: string): pg.PoolConfig { + // Manual parsing to handle special chars in password (/, =, etc.) + const match = url.match(/^postgres(?:ql)?:\/\/([^:]+):(.+)@([^:]+):(\d+)\/(.+)$/); + if (match) { + return { user: match[1], password: match[2], host: match[3], port: parseInt(match[4]), database: match[5] }; + } + return { connectionString: url }; +} + function getPool(): pg.Pool { if (!pool) { pool = new Pool({ - connectionString: serverConfig.coolifyDbUrl, + ...parseDbUrl(serverConfig.coolifyDbUrl), max: 3, idleTimeoutMillis: 30000, connectionTimeoutMillis: 5000,