From ea2fddc5cb28a82ed2d41cf53bcd84cc73ea29c5 Mon Sep 17 00:00:00 2001 From: Chris Farhood Date: Mon, 4 May 2026 16:22:41 +0000 Subject: [PATCH] fix(auth): support /auth/health path and align db response with tests - Add /auth/health as additional health check route (Envoy forwards full path) - Change db status 'connected' to 'reachable' to match health.test.ts - Only pass /auth/* routes to Better-Auth handler to prevent 404 on unknown routes Co-Authored-By: Paperclip --- auth/src/index.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/auth/src/index.ts b/auth/src/index.ts index 708d91d..c5d2f88 100644 --- a/auth/src/index.ts +++ b/auth/src/index.ts @@ -8,7 +8,7 @@ const handler = toNodeHandler(auth); const server = createServer(async (req, res) => { // Health check - if (req.url === "/health" && req.method === "GET") { + if ((req.url === "/health" || req.url === "/auth/health") && req.method === "GET") { try { const client = await pool.connect(); try { @@ -20,7 +20,7 @@ const server = createServer(async (req, res) => { client.release(); } res.writeHead(200, { "Content-Type": "application/json" }); - res.end(JSON.stringify({ status: "ok", db: "connected" })); + res.end(JSON.stringify({ status: "ok", db: "reachable" })); } catch { res.writeHead(503, { "Content-Type": "application/json" }); res.end(JSON.stringify({ status: "error", db: "unreachable" })); @@ -29,7 +29,10 @@ const server = createServer(async (req, res) => { } // All /auth/* routes handled by Better-Auth - await handler(req, res); + if (req.url?.startsWith("/auth")) { + await handler(req, res); + return; + } }); server.listen(port, "0.0.0.0", () => {