Monitor connected apps, review incidents, onboard new projects, and keep your operational contract in one calm place.
/api/health or /api/health/live so Watchtower can verify basic uptime./api/health/ready for deeper checks like database, storage, or queue readiness.WATCHTOWER_HEALTH_TOKEN in the app and the same token in Watchtower.console.error and expected auth/session churn stays at console.warn or is suppressed.WATCHTOWER_HEALTH_TOKEN=shared-secret-from-watchtower
app/api/health/live/route.ts
import { NextResponse } from 'next/server'
export async function GET() {
return NextResponse.json({
status: 'ok',
service: 'your-app',
environment: process.env.NODE_ENV ?? 'production',
timestamp: new Date().toISOString(),
})
}
app/api/health/ready/route.ts
import { NextRequest, NextResponse } from 'next/server'
export async function GET(req: NextRequest) {
const token = req.headers.get('authorization')?.replace(/^Bearer\s+/i, '').trim()
if (!process.env.WATCHTOWER_HEALTH_TOKEN || token !== process.env.WATCHTOWER_HEALTH_TOKEN) {
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 })
}
return NextResponse.json({
status: 'ok',
service: 'your-app',
checks: { env: 'ok', database: 'ok' },
timestamp: new Date().toISOString(),
})
}