- Add CLAUDE.md at root and AGENTS.md in apps/api, apps/indexer, apps/backoffice, crates/parsers with module-specific guidelines - Unify all service ports to 70XX (no more internal/external split): API 7080, Indexer 7081, Backoffice 7082 - Update docker-compose.yml, Dockerfiles, config.rs defaults, .env.example, backoffice routes, bench.sh, smoke.sh Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
44 lines
1.2 KiB
TypeScript
44 lines
1.2 KiB
TypeScript
import { NextRequest, NextResponse } from "next/server";
|
|
|
|
export async function GET(
|
|
request: NextRequest,
|
|
{ params }: { params: Promise<{ bookId: string }> }
|
|
) {
|
|
const { bookId } = await params;
|
|
|
|
const apiBaseUrl = process.env.API_BASE_URL || "http://api:7080";
|
|
const apiUrl = `${apiBaseUrl}/books/${bookId}/thumbnail`;
|
|
|
|
const token = process.env.API_BOOTSTRAP_TOKEN;
|
|
if (!token) {
|
|
return new NextResponse("API token not configured", { status: 500 });
|
|
}
|
|
|
|
try {
|
|
const response = await fetch(apiUrl, {
|
|
headers: {
|
|
Authorization: `Bearer ${token}`,
|
|
},
|
|
});
|
|
|
|
if (!response.ok) {
|
|
return new NextResponse(`Failed to fetch thumbnail: ${response.status}`, {
|
|
status: response.status
|
|
});
|
|
}
|
|
|
|
const contentType = response.headers.get("content-type") || "image/webp";
|
|
const imageBuffer = await response.arrayBuffer();
|
|
|
|
return new NextResponse(imageBuffer, {
|
|
headers: {
|
|
"Content-Type": contentType,
|
|
"Cache-Control": "public, max-age=31536000, immutable",
|
|
},
|
|
});
|
|
} catch (error) {
|
|
console.error("Error fetching thumbnail:", error);
|
|
return new NextResponse("Failed to fetch thumbnail", { status: 500 });
|
|
}
|
|
}
|