fix: normalize dashboard export buffers

This commit is contained in:
Esdras Renan 2025-11-06 14:36:59 -03:00
parent 0f0f367b3a
commit 164d72e3ce

View file

@ -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",