Skip to content

Commit 6a429d2

Browse files
committed
Expose frontend revision internally
1 parent 778cc18 commit 6a429d2

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ RUN rm -rf orval.config.ts cypress.config.ts cypress/ docs/ scripts/ lighthouse-
1919
FROM gcr.io/distroless/nodejs24-debian13 AS runner
2020

2121
WORKDIR /opt/app
22+
ARG APP_VERSION
2223
ENV NODE_ENV=production
24+
ENV APP_VERSION=${APP_VERSION}
2325

2426
COPY --from=builder --chown=nonroot:nonroot /opt/app/next.config.js ./
2527
COPY --from=builder --chown=nonroot:nonroot /opt/app/public ./public

app/api/version/route.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
export const dynamic = 'force-dynamic'
2+
3+
const internalHost = 'hypixel-react.sky.svc.cluster.local'
4+
5+
export function GET(request: Request) {
6+
const host = request.headers.get('host')?.split(':')[0]
7+
if (host !== internalHost) return new Response(null, { status: 404 })
8+
9+
const version = process.env.APP_VERSION ?? ''
10+
if (!/^[a-f0-9]{40}$/i.test(version)) return new Response('APP_VERSION is not configured', { status: 503 })
11+
12+
return new Response(version, {
13+
headers: {
14+
'Cache-Control': 'no-store',
15+
'Content-Type': 'text/plain; charset=utf-8'
16+
}
17+
})
18+
}

0 commit comments

Comments
 (0)