fix: normalize dashboard export buffers
This commit is contained in:
parent
0f0f367b3a
commit
164d72e3ce
1 changed files with 4 additions and 6 deletions
|
|
@ -146,10 +146,9 @@ export async function GET(
|
||||||
right: "18px",
|
right: "18px",
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
const bytes = pdfBuffer instanceof Uint8Array ? pdfBuffer : new Uint8Array(pdfBuffer)
|
const bytes = new Uint8Array(pdfBuffer)
|
||||||
const arrayBuffer = bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength)
|
|
||||||
const filename = slugifyFilename(detail.dashboard.name ?? "dashboard", "pdf")
|
const filename = slugifyFilename(detail.dashboard.name ?? "dashboard", "pdf")
|
||||||
return new NextResponse(arrayBuffer, {
|
return new NextResponse(bytes, {
|
||||||
status: 200,
|
status: 200,
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/pdf",
|
"Content-Type": "application/pdf",
|
||||||
|
|
@ -160,10 +159,9 @@ export async function GET(
|
||||||
}
|
}
|
||||||
|
|
||||||
const screenshot = await page.screenshot({ type: "png", fullPage: true })
|
const screenshot = await page.screenshot({ type: "png", fullPage: true })
|
||||||
const bytes = screenshot instanceof Uint8Array ? screenshot : new Uint8Array(screenshot)
|
const bytes = new Uint8Array(screenshot)
|
||||||
const arrayBuffer = bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength)
|
|
||||||
const filename = slugifyFilename(detail.dashboard.name ?? "dashboard", "png")
|
const filename = slugifyFilename(detail.dashboard.name ?? "dashboard", "png")
|
||||||
return new NextResponse(arrayBuffer, {
|
return new NextResponse(bytes, {
|
||||||
status: 200,
|
status: 200,
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "image/png",
|
"Content-Type": "image/png",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue