Skip to content

Commit b203bdc

Browse files
author
flowcore-platform
committed
fix: add /health endpoint for Kubernetes probes
Kubernetes probes were checking /health but the endpoint was at /api/health, causing readiness probe failures and 502 errors. Added new /health route at the root to match probe configuration and excluded it from middleware. Changes: - Add app/health/route.ts for Kubernetes probes at /health - Exclude /health from middleware matcher (in addition to /api/health) - Fixes 502 Bad Gateway by properly responding to health checks
1 parent d460a9f commit b203bdc

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

app/health/route.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { NextResponse } from "next/server"
2+
3+
export const dynamic = "force-dynamic"
4+
export const runtime = "nodejs"
5+
6+
/**
7+
* Public health check endpoint for Kubernetes probes
8+
* Used to verify the application is running and responding
9+
* Located at /health (not /api/health) to match Kubernetes probe configuration
10+
*/
11+
export async function GET() {
12+
return NextResponse.json({
13+
status: "ok",
14+
timestamp: new Date().toISOString(),
15+
service: "graphable",
16+
version: process.env.npm_package_version || "unknown",
17+
})
18+
}

middleware.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,6 @@ export default withAuth(
7575

7676
export const config = {
7777
matcher: [
78-
"/((?!_next/static|_next/image|favicon.ico|api/health|.*\\.(?:svg|png|jpg|jpeg|gif|webp)$).*)",
78+
"/((?!_next/static|_next/image|favicon.ico|health|api/health|.*\\.(?:svg|png|jpg|jpeg|gif|webp)$).*)",
7979
],
8080
}

0 commit comments

Comments
 (0)