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

This commit is contained in:
twotalesanimation
2026-07-16 23:12:58 +02:00
parent e756eb9015
commit 384a7770ea
+9 -4
View File
@@ -47,15 +47,20 @@ export async function GET(
// ── Hetzner first, local disk fallback ───────────────────────────────────
// Check object storage first (all new uploads go there directly; migrated
// files live there too). Results are cached in process memory after the
// first check so subsequent range requests pay no extra latency.
// Fall back to local disk only for files that haven't been migrated yet.
let stat: fs.Stats;
// files live there too). Each try/catch is isolated so a Hetzner error
// never prevents local files from being served.
try {
if (await hetznerKeyExists(relativePath)) {
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;
try {
stat = fs.statSync(filePath);
} catch {
return new NextResponse("Not found", { status: 404 });