import fs from "node:fs"; import path from "node:path"; import type { APIRoute } from "astro"; export const prerender = false; export const GET: APIRoute = ({ params }) => { const file = params.file; const filePath = path.join(process.env.PHOTO_DIR_ABSOLUTE_PATH!, file!); if (!fs.existsSync(filePath)) { return new Response("Image introuvable", { status: 404 }); } const image = fs.readFileSync(filePath); return new Response(image, { headers: { "Content-Type": "image/jpeg", "Cache-Control": "public, max-age=31536000", }, }); };