From 337b50a6f5b0c3df3e2da89096a20c3a4e9a7ce9 Mon Sep 17 00:00:00 2001 From: Julien Froidefond Date: Wed, 12 Feb 2025 08:51:46 +0100 Subject: [PATCH] =?UTF-8?q?refactor:=20suppression=20de=20la=20route=20thu?= =?UTF-8?q?mbnail=20g=C3=A9n=C3=A9rique=20(remplac=C3=A9e=20par=20des=20ro?= =?UTF-8?q?utes=20sp=C3=A9cifiques)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/komga/thumbnail/[...path]/route.ts | 54 ------------------- 1 file changed, 54 deletions(-) delete mode 100644 src/app/api/komga/thumbnail/[...path]/route.ts diff --git a/src/app/api/komga/thumbnail/[...path]/route.ts b/src/app/api/komga/thumbnail/[...path]/route.ts deleted file mode 100644 index 9991038..0000000 --- a/src/app/api/komga/thumbnail/[...path]/route.ts +++ /dev/null @@ -1,54 +0,0 @@ -import { NextResponse } from "next/server"; -import { cookies } from "next/headers"; - -export async function GET(request: Request, { params }: { params: { path: string[] } }) { - try { - // Récupérer les credentials Komga depuis le cookie - const configCookie = cookies().get("komga_credentials"); - if (!configCookie) { - return NextResponse.json({ error: "Configuration Komga manquante" }, { status: 401 }); - } - - let config; - try { - config = JSON.parse(atob(configCookie.value)); - } catch (error) { - return NextResponse.json({ error: "Configuration Komga invalide" }, { status: 401 }); - } - - // Reconstruire le chemin de l'image - const imagePath = params.path.join("/"); - const imageUrl = `${config.serverUrl}/api/v1/${imagePath}`; - - // Appel à l'API Komga - const response = await fetch(imageUrl, { - headers: { - Authorization: `Basic ${Buffer.from( - `${config.credentials?.username}:${config.credentials?.password}` - ).toString("base64")}`, - }, - }); - - if (!response.ok) { - return NextResponse.json( - { error: "Erreur lors de la récupération de l'image" }, - { status: response.status } - ); - } - - // Récupérer les headers de l'image - const contentType = response.headers.get("content-type"); - const buffer = await response.arrayBuffer(); - - // Retourner l'image avec les bons headers - return new NextResponse(buffer, { - headers: { - "Content-Type": contentType || "image/jpeg", - "Cache-Control": "public, max-age=31536000", - }, - }); - } catch (error) { - console.error("Erreur lors de la récupération de l'image:", error); - return NextResponse.json({ error: "Erreur serveur" }, { status: 500 }); - } -}