From b5a416bc2133dd5ce817ed1363dfb1dd07181824 Mon Sep 17 00:00:00 2001 From: 732642856 <732642856@qq.com> Date: Sun, 19 Jul 2026 09:24:38 +0800 Subject: [PATCH] chore: expose deployment identity in health --- frontend/src/app/api/health/route.ts | 8 ++++++++ frontend/tests/health-deployment.test.ts | 12 ++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 frontend/tests/health-deployment.test.ts diff --git a/frontend/src/app/api/health/route.ts b/frontend/src/app/api/health/route.ts index 776dce61..e8cab627 100644 --- a/frontend/src/app/api/health/route.ts +++ b/frontend/src/app/api/health/route.ts @@ -7,6 +7,11 @@ type Check = { }; const jyotishApiBase = process.env.JYOTISH_API_BASE ?? "http://127.0.0.1:5200"; +const gitCommit = + process.env.GITHUB_SHA + ?? process.env.VERCEL_GIT_COMMIT_SHA + ?? process.env.NEXT_PUBLIC_GIT_COMMIT + ?? "unknown"; function envCheck(names: string[]): Check { const missing = names.filter((name) => !process.env[name]); @@ -65,6 +70,9 @@ export async function GET() { { status, timestamp: new Date().toISOString(), + deployment: { + gitCommit, + }, checks, }, { status: status === "ok" ? 200 : 503 }, diff --git a/frontend/tests/health-deployment.test.ts b/frontend/tests/health-deployment.test.ts new file mode 100644 index 00000000..d6add901 --- /dev/null +++ b/frontend/tests/health-deployment.test.ts @@ -0,0 +1,12 @@ +import assert from "node:assert/strict"; +import { readFileSync } from "node:fs"; +import test from "node:test"; + +test("health endpoint exposes deployment identity for production verification", () => { + const source = readFileSync(new URL("../src/app/api/health/route.ts", import.meta.url), "utf8"); + + assert.match(source, /deployment:/); + assert.match(source, /GITHUB_SHA/); + assert.match(source, /VERCEL_GIT_COMMIT_SHA/); + assert.match(source, /gitCommit/); +});