BIG MOOOOVE to Object Storage
Deploy / deploy (push) Successful in 2m43s

This commit is contained in:
twotalesanimation
2026-07-16 22:15:58 +02:00
parent 3264abb432
commit 745634f1b6
10 changed files with 594 additions and 17 deletions
+10 -1
View File
@@ -1,6 +1,7 @@
import { NextRequest, NextResponse } from "next/server";
import fs from "fs";
import path from "path";
import { generateHetznerStreamUrl } from "@/lib/storage";
// ── Tuning constants ──────────────────────────────────────────────────────────
//
@@ -50,7 +51,15 @@ export async function GET(
try {
stat = fs.statSync(filePath);
} catch {
return new NextResponse("Not found", { status: 404 });
// File not on local disk — attempt a redirect to Hetzner object storage.
// This covers files uploaded after the migration and any migrated files
// whose local copies have been removed.
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