perf: skip Next.js image re-optimization and stream proxy responses

Thumbnails are already optimized (WebP) by the API, so disable Next.js
image optimization to avoid redundant CPU work. Switch route handlers
from buffering (arrayBuffer) to streaming (response.body) to reduce
memory usage and latency.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-22 06:38:46 +01:00
parent 3a25e42a20
commit 92f80542e6
3 changed files with 14 additions and 17 deletions

View File

@@ -21,19 +21,16 @@ export async function GET(
const response = await fetch(apiUrl.toString(), {
headers: { Authorization: `Bearer ${token}` },
});
if (!response.ok) {
return new NextResponse(`Failed to fetch image: ${response.status}`, {
status: response.status
return new NextResponse(`Failed to fetch image: ${response.status}`, {
status: response.status
});
}
// Récupérer le content-type et les données
const contentType = response.headers.get("content-type") || "image/webp";
const imageBuffer = await response.arrayBuffer();
// Retourner l'image avec le bon content-type
return new NextResponse(imageBuffer, {
return new NextResponse(response.body, {
headers: {
"Content-Type": contentType,
"Cache-Control": "public, max-age=300",