import { crmFetch } from '../../../../../../lib/flats'; /** Фото квартиры из CRM (обрезанное там же); кешируется браузером на сутки */ export async function GET(_req: Request, { params }: { params: Promise<{ id: string; index: string }> }) { const { id, index } = await params; if (!/^\d{1,9}$/.test(id) || !/^\d{1,2}$/.test(index)) return new Response(null, { status: 404 }); try { const res = await crmFetch(`/api/barev/objects/${id}/photos/${index}`, { next: { revalidate: 86_400 }, }); if (!res.ok) return new Response(null, { status: 404 }); return new Response(res.body, { headers: { 'content-type': 'image/jpeg', 'cache-control': 'public, max-age=86400, stale-while-revalidate=604800', }, }); } catch { return new Response(null, { status: 502 }); } }