fix(admin): serve media from private storage
This commit is contained in:
parent
d9da86dd46
commit
faddaa91d0
14 changed files with 114 additions and 20 deletions
|
|
@ -37,7 +37,7 @@ export default async function AdminSystemPage() {
|
|||
<h2>Betriebsregeln</h2>
|
||||
<ul className="list">
|
||||
<li>Runtime-Daten liegen unter <code>data/</code> und werden nicht versioniert.</li>
|
||||
<li>Uploads liegen unter <code>public/uploads/images/</code> und werden nicht versioniert.</li>
|
||||
<li>Uploads liegen unter <code>storage/uploads/images/</code> und werden nicht versioniert.</li>
|
||||
<li>Olympus- und SMTP-Integration sind vorbereitet, aber nicht aktiv implementiert.</li>
|
||||
</ul>
|
||||
</section>
|
||||
|
|
|
|||
22
app/api/media/[filename]/route.ts
Normal file
22
app/api/media/[filename]/route.ts
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
import { NextResponse } from "next/server";
|
||||
import { readMediaFile } from "@/lib/admin/media";
|
||||
|
||||
export async function GET(_request: Request, { params }: { params: Promise<{ filename: string }> }) {
|
||||
const { filename } = await params;
|
||||
const media = await readMediaFile(decodeURIComponent(filename));
|
||||
|
||||
if (!media) {
|
||||
return NextResponse.json({ message: "Datei nicht gefunden." }, { status: 404 });
|
||||
}
|
||||
|
||||
return new NextResponse(media.data, {
|
||||
status: 200,
|
||||
headers: {
|
||||
"Content-Type": media.mimeType,
|
||||
"Content-Length": String(media.size),
|
||||
"Content-Disposition": "inline",
|
||||
"Cache-Control": "private, max-age=300",
|
||||
"X-Content-Type-Options": "nosniff",
|
||||
},
|
||||
});
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue