2-update driver pages [fixed image display and notyfi] 3-update car pages [fixed image] 4-build tripe pages crud 5-build some role pages 6-build audit page 7-update ui compounants 8-update saidebar and topbar 9-cheange view to be ar view 10-cheange stractcher to be app,src 11-add validation layer by yup 12-add api image-proxy to broke image corse bloken
35 lines
907 B
TypeScript
35 lines
907 B
TypeScript
import { NextRequest, NextResponse } from "next/server";
|
|
|
|
const BACKEND_BASE = "https://logiapi.slash.sa";
|
|
|
|
export async function GET(
|
|
_req: NextRequest,
|
|
{ params }: { params: Promise<{ filename: string }> },
|
|
) {
|
|
const { filename } = await params;
|
|
|
|
try {
|
|
const upstream = await fetch(
|
|
`${BACKEND_BASE}/public/uploads/driver-photos/${filename}`,
|
|
{ cache: "no-store" },
|
|
);
|
|
|
|
if (!upstream.ok) {
|
|
return new NextResponse(null, { status: upstream.status });
|
|
}
|
|
|
|
const buffer = await upstream.arrayBuffer();
|
|
const contentType =
|
|
upstream.headers.get("Content-Type") ?? "image/jpeg";
|
|
|
|
return new NextResponse(buffer, {
|
|
status: 200,
|
|
headers: {
|
|
"Content-Type": contentType,
|
|
"Cache-Control": "public, max-age=3600, stale-while-revalidate=86400",
|
|
},
|
|
});
|
|
} catch {
|
|
return new NextResponse(null, { status: 502 });
|
|
}
|
|
} |