diff --git a/src/routes/customers.ts b/src/routes/customers.ts index 54784eb..a6f8dd4 100644 --- a/src/routes/customers.ts +++ b/src/routes/customers.ts @@ -240,9 +240,11 @@ export async function customerRoutes(app: FastifyInstance) { await sql.end(); } })(), - // Try connecting via pgbouncer + // Try connecting via pgbouncer using the customer's db url from k8s secret (async () => { - const sql = postgres(`postgresql://${slug}@${PGBOUNCER_HOST}:${PGBOUNCER_PORT}/${slug}`, { max: 1, connect_timeout: 5 }); + const secrets = await getSecret(namespace, "lunarfront-secrets").catch(() => null); + if (!secrets?.["database-url"]) return false; + const sql = postgres(secrets["database-url"], { max: 1, connect_timeout: 5 }); try { await sql`SELECT 1`; return true;