OBJ then local reverse
Deploy / deploy (push) Successful in 2m44s

This commit is contained in:
twotalesanimation
2026-07-16 23:19:02 +02:00
parent 384a7770ea
commit 96c0f2b84f
+13 -15
View File
@@ -45,25 +45,23 @@ export async function GET(
return new NextResponse("Forbidden", { status: 403 }); return new NextResponse("Forbidden", { status: 403 });
} }
// ── Hetzner first, local disk fallback ─────────────────────────────────── // ── Local disk first, Hetzner fallback ───────────────────────────────────
// Check object storage first (all new uploads go there directly; migrated // Serve from local disk if the file exists there (covers unmigrated files).
// files live there too). Each try/catch is isolated so a Hetzner error // If not found locally, redirect to Hetzner object storage.
// never prevents local files from being served. // Note: "Hetzner first" was attempted but caused 400s from Hetzner on
try { // presigned URLs — likely a bucket policy/CORS issue to investigate
if (await hetznerKeyExists(relativePath)) { // separately before re-enabling that path.
const hetznerUrl = await generateHetznerStreamUrl(relativePath, 3600);
return NextResponse.redirect(hetznerUrl, 302);
}
} catch {
// Hetzner unavailable or misconfigured — fall through to local disk
}
// Local disk fallback (unmigrated files, or if Hetzner is unreachable)
let stat: fs.Stats; let stat: fs.Stats;
try { try {
stat = fs.statSync(filePath); stat = fs.statSync(filePath);
} catch { } catch {
return new NextResponse("Not found", { status: 404 }); // Not on local disk — try Hetzner
try {
const hetznerUrl = await generateHetznerStreamUrl(relativePath, 3600);
return NextResponse.redirect(hetznerUrl, 302);
} catch {
return new NextResponse("Not found", { status: 404 });
}
} }
// Guard against directory traversal that resolves to a directory // Guard against directory traversal that resolves to a directory