From 164d72e3cec638c37ced4fd50e6168d08c8cb21a Mon Sep 17 00:00:00 2001 From: Esdras Renan Date: Thu, 6 Nov 2025 14:36:59 -0300 Subject: [PATCH] fix: normalize dashboard export buffers --- src/app/api/dashboards/[id]/export/[format]/route.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/app/api/dashboards/[id]/export/[format]/route.ts b/src/app/api/dashboards/[id]/export/[format]/route.ts index 6ddf660..264aaeb 100644 --- a/src/app/api/dashboards/[id]/export/[format]/route.ts +++ b/src/app/api/dashboards/[id]/export/[format]/route.ts @@ -146,10 +146,9 @@ export async function GET( right: "18px", }, }) - const bytes = pdfBuffer instanceof Uint8Array ? pdfBuffer : new Uint8Array(pdfBuffer) - const arrayBuffer = bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength) + const bytes = new Uint8Array(pdfBuffer) const filename = slugifyFilename(detail.dashboard.name ?? "dashboard", "pdf") - return new NextResponse(arrayBuffer, { + return new NextResponse(bytes, { status: 200, headers: { "Content-Type": "application/pdf", @@ -160,10 +159,9 @@ export async function GET( } const screenshot = await page.screenshot({ type: "png", fullPage: true }) - const bytes = screenshot instanceof Uint8Array ? screenshot : new Uint8Array(screenshot) - const arrayBuffer = bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength) + const bytes = new Uint8Array(screenshot) const filename = slugifyFilename(detail.dashboard.name ?? "dashboard", "png") - return new NextResponse(arrayBuffer, { + return new NextResponse(bytes, { status: 200, headers: { "Content-Type": "image/png",