From 8ba8604d8308589ca8fef5c10b1445945ece723e Mon Sep 17 00:00:00 2001 From: MartinBraquet Date: Sun, 1 Mar 2026 02:55:10 +0100 Subject: [PATCH] Add /health to vercel API --- web/pages/api/health.ts | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 web/pages/api/health.ts diff --git a/web/pages/api/health.ts b/web/pages/api/health.ts new file mode 100644 index 00000000..7ca934d2 --- /dev/null +++ b/web/pages/api/health.ts @@ -0,0 +1,27 @@ +import type {NextApiRequest, NextApiResponse} from 'next' + +type HealthResponse = { + status: 'healthy' | 'unhealthy' + timestamp: string + version: string + uptime: number +} + +export default function handler(req: NextApiRequest, res: NextApiResponse) { + res.setHeader('Access-Control-Allow-Origin', '*') + res.setHeader('Access-Control-Allow-Methods', 'GET, OPTIONS') + res.setHeader('Access-Control-Allow-Headers', 'Content-Type') + + if (req.method === 'OPTIONS') { + res.status(200).end() + return + } + + res.setHeader('Cache-Control', 'no-store') + res.status(200).json({ + status: 'healthy', + timestamp: new Date().toISOString(), + version: process.env.NEXT_PUBLIC_APP_VERSION || 'unknown', + uptime: process.uptime(), + }) +}