19 lines
812 B
TypeScript
19 lines
812 B
TypeScript
import type { NextRequest } from "next/server";
|
|
import { DC_FILE_DOWNLOAD_PATH } from "@/entities/datalibrary/api/source-file-reference";
|
|
import { downloadFailure } from "@/server/dc-attachment";
|
|
|
|
export const dynamic = "force-dynamic";
|
|
|
|
// Previously issued revision QR codes point here. Resolve them using the scanning user's DC request.
|
|
export function GET(request: NextRequest): Response {
|
|
const params = request.nextUrl.searchParams;
|
|
const fileSn = params.get("fileSn");
|
|
const revisionId = params.get("revisionId");
|
|
if (params.size !== 2 || !fileSn || !revisionId || fileSn.length > 256 || revisionId.length > 512) {
|
|
return downloadFailure(400);
|
|
}
|
|
return new Response(null, {
|
|
status: 307, headers: { Location: `${DC_FILE_DOWNLOAD_PATH}?${params}`, "Cache-Control": "no-store" },
|
|
});
|
|
}
|