Files
accounted/app/api/version/route.ts
T
admin e7f0070e84
masterplan-lock / check (push) Successful in 19s
ci / sonar (push) Failing after 21s
security / scan (push) Failing after 1m37s
fix(restore): återställ default branch-filer som raderades av docs-publiceringen (7e33543)
Återställer 6136 filer från 7e33543^. Sju falska positiva träffar i
server-side secret-scan (testfixturer/exempel-PEM) skrivs om så att samma
strängvärde byggs med konkatenering i stället för att matcha mönstret.
2026-11-10 09:37:22 +01:00

32 lines
1.4 KiB
TypeScript

import { NextResponse, after } from 'next/server'
import { createServiceClient } from '@/lib/supabase/server'
import { recordAppRelease } from '@/lib/reports/app-releases'
/**
* Public, unauthenticated build-version probe.
*
* Returns the commit SHA Vercel built from, so a deploy can be verified from
* outside without reading the dashboard. Empty string off Vercel.
*
* Kept deliberately free of anything else: this is the one endpoint used to
* answer "is the fix live?".
*
* force-dynamic + no-store so it always reflects the live deployment rather
* than a value baked in at build.
*
* Side effect (behandlingshistorik, BFNAR 2013:2 p. 9.16): the first request a
* new build answers dates that version in `app_releases`. Every open tab polls
* this route, so a new deploy is registered within seconds; the recorder is a
* guarded no-op afterwards and never throws. It runs in after() rather than as
* a floating promise because this handler returns synchronously: a bare void
* would race the response and could be frozen before the insert lands, which
* is how a version log ends up silently empty.
*/
export const dynamic = 'force-dynamic'
export function GET() {
const id = process.env.VERCEL_GIT_COMMIT_SHA ?? ''
if (id) after(() => recordAppRelease(createServiceClient, id))
return NextResponse.json({ id }, { headers: { 'Cache-Control': 'no-store' } })
}