2026-05-16 11:51:11 +07:00
|
|
|
import { execSync } from "child_process";
|
2026-05-16 12:08:27 +07:00
|
|
|
import { NextResponse } from "next/server";
|
|
|
|
|
|
|
|
|
|
export const dynamic = "force-dynamic";
|
2026-05-16 11:51:11 +07:00
|
|
|
|
|
|
|
|
export function GET() {
|
2026-05-16 12:08:27 +07:00
|
|
|
if (process.env.NODE_ENV !== "development") {
|
2026-05-31 03:03:49 +07:00
|
|
|
return NextResponse.json({
|
|
|
|
|
hash: process.env.NEXT_PUBLIC_GIT_HASH || "unknown",
|
|
|
|
|
});
|
2026-05-16 12:08:27 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
2026-05-31 03:03:49 +07:00
|
|
|
const hash = execSync("git rev-parse --short HEAD", { cwd: process.cwd() })
|
|
|
|
|
.toString()
|
|
|
|
|
.trim();
|
2026-05-16 12:08:27 +07:00
|
|
|
return NextResponse.json({ hash });
|
|
|
|
|
} catch {
|
|
|
|
|
return NextResponse.json({ hash: "unknown" });
|
|
|
|
|
}
|
|
|
|
|
}
|