Without a health check, a bad merge or broken container startup can take your service down. A minimal health endpoint is the last line of defense before Kubernetes sends live traffic to a new pod.
A simple Next.js endpoint
Keep the endpoint fast and free of noisy downstream checks unless you actually want failing dependencies to pull pods out of rotation:
// src/pages/api/health.js (or src/app/api/health/route.js)
export default function handler(req, res) {
res.status(200).json({ status: "OK" });
}
Wiring startupProbe in Kubernetes
startupProbe:
httpGet:
path: /api/health
port: 3000
initialDelaySeconds: 1
failureThreshold: 10
periodSeconds: 6
That holds traffic off the pod until Next.js actually binds port 3000 and returns 200 OK. If you use an APM tracer like dd-trace, add /api/health to its HTTP blocklist too so probe requests do not clutter your traces.