fix(frontend): Add health check API endpoint for Docker monitoring
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 <noreply@anthropic.com>
This commit is contained in:
26
app/api/health/route.ts
Normal file
26
app/api/health/route.ts
Normal file
@@ -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 });
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user