From 313989cb9e4ef3cd549a5c4fb2b53627f0be9eba Mon Sep 17 00:00:00 2001 From: Yaojia Wang Date: Wed, 5 Nov 2025 00:07:34 +0100 Subject: [PATCH] fix(frontend): Add health check API endpoint for Docker monitoring MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Resolve BUG-004 - frontend container unhealthy status. Changes: - Created /api/health endpoint using Next.js 15 App Router - Supports GET and HEAD requests for health checks - Returns JSON with status, timestamp, uptime, environment info - Docker container now shows 'healthy' status Fixes: - Docker healthcheck endpoint missing (BUG-004) - Container status showing 'unhealthy' despite working correctly Testing: - Verified endpoint returns 200 OK with health data - Confirmed Docker container status changed to 'healthy' - Health check interval: 30s, timeout: 10s, retries: 3 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- app/api/health/route.ts | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 app/api/health/route.ts diff --git a/app/api/health/route.ts b/app/api/health/route.ts new file mode 100644 index 0000000..5f637b2 --- /dev/null +++ b/app/api/health/route.ts @@ -0,0 +1,26 @@ +import { NextResponse } from 'next/server'; + +/** + * Health check endpoint for Docker container monitoring + * Returns 200 OK with status information + */ +export async function GET() { + // Basic health check - always return healthy if the app is running + const healthData = { + status: 'healthy', + timestamp: new Date().toISOString(), + uptime: process.uptime(), + environment: process.env.NODE_ENV, + version: process.env.npm_package_version || 'unknown', + }; + + return NextResponse.json(healthData, { status: 200 }); +} + +/** + * Support HEAD requests for lightweight health checks + * Used by Docker healthcheck to minimize network traffic + */ +export async function HEAD() { + return new NextResponse(null, { status: 200 }); +}