Initial commit - ERP System

This commit is contained in:
root
2026-05-20 18:58:23 +00:00
commit e174936997
2697 changed files with 1628427 additions and 0 deletions
+16
View File
@@ -0,0 +1,16 @@
import { NextResponse } from 'next/server';
import { readFile } from 'fs/promises';
import path from 'path';
export async function GET(request: Request, context: { params: Promise<{ name: string }> }) {
try {
const { name } = await context.params;
const filePath = path.join(process.cwd(), 'uploads', 'products', name);
const buffer = await readFile(filePath);
const ext = name.split('.').pop()?.toLowerCase();
const contentType = ext === 'png' ? 'image/png' : ext === 'webp' ? 'image/webp' : ext === 'gif' ? 'image/gif' : 'image/jpeg';
return new NextResponse(buffer, { headers: { 'Content-Type': contentType, 'Cache-Control': 'public, max-age=86400' } });
} catch {
return NextResponse.json({ error: 'Bild nicht gefunden' }, { status: 404 });
}
}