From 24b9091c05b7bee1e6eb1f247e6ba4f175db98ad Mon Sep 17 00:00:00 2001 From: trafficlunar Date: Mon, 18 Aug 2025 22:18:11 +0100 Subject: [PATCH] fix: convert buffers to Uint8Array types issue --- src/app/profile/[id]/picture/route.ts | 2 +- src/lib/rate-limit.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/profile/[id]/picture/route.ts b/src/app/profile/[id]/picture/route.ts index 3f15f22..a050da7 100644 --- a/src/app/profile/[id]/picture/route.ts +++ b/src/app/profile/[id]/picture/route.ts @@ -20,7 +20,7 @@ export async function GET(request: NextRequest, { params }: { params: Promise<{ try { const buffer = await fs.readFile(filePath); - return new NextResponse(buffer); + return new NextResponse(new Uint8Array(buffer)); // convert to Uint8Array due to weird types issue } catch { return rateLimit.sendResponse({ error: "Image not found" }, 404); } diff --git a/src/lib/rate-limit.ts b/src/lib/rate-limit.ts index 6a335e8..9375669 100644 --- a/src/lib/rate-limit.ts +++ b/src/lib/rate-limit.ts @@ -73,7 +73,7 @@ export class RateLimit { let response: NextResponse; if (Buffer.isBuffer(body)) { - response = new NextResponse(body, { status, headers }); + response = new NextResponse(new Uint8Array(body), { status, headers }); // convert to Uint8Array due to weird types issue } else { response = NextResponse.json(body, { status, headers }); }