Files
vfxreview/app/api/ext/exports/latest/route.ts
T
twotalesanimation 9a49cdc6a3
Deploy / deploy (push) Failing after 1m52s
RenderPipeline2
2026-08-01 15:44:26 +02:00

26 lines
930 B
TypeScript

import { NextRequest, NextResponse } from "next/server";
import { getLatestExportForShot } from "@/lib/render-pipeline/exports";
function isAuthorized(req: NextRequest): boolean {
const apiKey = process.env.API_SECRET_KEY;
if (!apiKey) return false;
const authHeader = req.headers.get("authorization") ?? "";
if (authHeader.startsWith("Bearer ")) return authHeader.slice(7) === apiKey;
return (req.headers.get("x-api-key") ?? "") === apiKey;
}
export async function GET(req: NextRequest) {
if (!isAuthorized(req)) {
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
}
const { searchParams } = new URL(req.url);
const shotId = searchParams.get("shotId");
if (!shotId) {
return NextResponse.json({ error: "shotId query param is required" }, { status: 400 });
}
const exportRecord = await getLatestExportForShot(shotId);
return NextResponse.json({ export: exportRecord });
}