feat: ui commit hash versioning on prod

This commit is contained in:
2026-05-16 13:13:41 +07:00
parent f2f45f2509
commit bcf4650c70
4 changed files with 35 additions and 7 deletions
+14 -4
View File
@@ -1,7 +1,17 @@
import { NextResponse } from "next/server";
import { execSync } from "child_process";
import { NextResponse } from "next/server";
export const dynamic = "force-dynamic";
export function GET() {
const hash = execSync("git rev-parse --short HEAD").toString().trim();
return NextResponse.json({ hash });
}
if (process.env.NODE_ENV !== "development") {
return NextResponse.json({ hash: process.env.NEXT_PUBLIC_GIT_HASH || "unknown" });
}
try {
const hash = execSync("git rev-parse --short HEAD", { cwd: process.cwd() }).toString().trim();
return NextResponse.json({ hash });
} catch {
return NextResponse.json({ hash: "unknown" });
}
}