feat: support lan/tailnet endpoint selection for presigned URLs

This commit is contained in:
William Valentin
2026-02-05 10:10:53 -08:00
parent d93caedb31
commit 35e3cbf52f
6 changed files with 161 additions and 35 deletions

View File

@@ -39,10 +39,12 @@ export async function GET(
const kindParam = url.searchParams.get("kind");
const sizeParam = url.searchParams.get("size");
const legacyVariantParam = url.searchParams.get("variant");
const endpointParam = url.searchParams.get("endpoint");
let requestedKind: z.infer<typeof kindSchema> = "original";
let requestedSize: number | null = null;
let legacyVariant: z.infer<typeof legacyVariantSchema> | null = null;
let endpointOverride: "lan" | "tailnet" | undefined;
if (kindParam) {
const kindParsed = kindSchema.safeParse(kindParam);
@@ -81,6 +83,25 @@ export async function GET(
requestedSize = "size" in mapped ? mapped.size : null;
}
if (endpointParam) {
if (endpointParam !== "lan" && endpointParam !== "tailnet") {
return Response.json(
{
error: "invalid_query",
issues: [
{
code: "custom",
message: "endpoint must be lan or tailnet",
path: ["endpoint"],
},
],
},
{ status: 400 },
);
}
endpointOverride = endpointParam;
}
const db = getDb();
const rows = await db<
{
@@ -171,6 +192,7 @@ export async function GET(
key,
responseContentType,
responseContentDisposition,
endpoint: endpointOverride,
});
return Response.json(signed, {