Phase2: Invoicecomputation/AdminpricingUI/Ainvoicemgnt
Some checks failed
Build and Push / build (push) Failing after 47s
Some checks failed
Build and Push / build (push) Failing after 47s
This commit is contained in:
@@ -26,15 +26,17 @@ export async function GET(
|
|||||||
if (!pdf) {
|
if (!pdf) {
|
||||||
return new NextResponse("Not found", { status: 404 });
|
return new NextResponse("Not found", { status: 404 });
|
||||||
}
|
}
|
||||||
// Web `Response`'s `BodyInit` doesn't include Node's `Buffer` — pg
|
// Web `Response`'s BodyInit accepts BufferSource, which IS satisfied
|
||||||
// returns bytea as Buffer but Next/the runtime want a BufferSource.
|
// by a Uint8Array. But the pg-returned Buffer types as
|
||||||
// Wrap into a zero-copy Uint8Array view (Buffer extends Uint8Array
|
// `Uint8Array<ArrayBufferLike>` (the @types/node 22+ generic form),
|
||||||
// under the hood, but TypeScript treats them as distinct).
|
// and lib.dom's BufferSource only accepts `Uint8Array<ArrayBuffer>` —
|
||||||
const body = new Uint8Array(
|
// the narrower concrete form. The variance kills assignability,
|
||||||
pdf.data.buffer,
|
// even though Buffer extends Uint8Array at runtime.
|
||||||
pdf.data.byteOffset,
|
//
|
||||||
pdf.data.byteLength
|
// `Uint8Array.from(buf)` allocates a fresh typed array; the result
|
||||||
);
|
// is `Uint8Array<ArrayBuffer>` (concrete generic), which BodyInit
|
||||||
|
// accepts. Copy cost is trivial at PDF sizes.
|
||||||
|
const body = Uint8Array.from(pdf.data);
|
||||||
return new NextResponse(body, {
|
return new NextResponse(body, {
|
||||||
status: 200,
|
status: 200,
|
||||||
headers: {
|
headers: {
|
||||||
|
|||||||
Reference in New Issue
Block a user