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) {
|
||||
return new NextResponse("Not found", { status: 404 });
|
||||
}
|
||||
// Web `Response`'s `BodyInit` doesn't include Node's `Buffer` — pg
|
||||
// returns bytea as Buffer but Next/the runtime want a BufferSource.
|
||||
// Wrap into a zero-copy Uint8Array view (Buffer extends Uint8Array
|
||||
// under the hood, but TypeScript treats them as distinct).
|
||||
const body = new Uint8Array(
|
||||
pdf.data.buffer,
|
||||
pdf.data.byteOffset,
|
||||
pdf.data.byteLength
|
||||
);
|
||||
// Web `Response`'s BodyInit accepts BufferSource, which IS satisfied
|
||||
// by a Uint8Array. But the pg-returned Buffer types as
|
||||
// `Uint8Array<ArrayBufferLike>` (the @types/node 22+ generic form),
|
||||
// and lib.dom's BufferSource only accepts `Uint8Array<ArrayBuffer>` —
|
||||
// the narrower concrete form. The variance kills assignability,
|
||||
// even though Buffer extends Uint8Array at runtime.
|
||||
//
|
||||
// `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, {
|
||||
status: 200,
|
||||
headers: {
|
||||
|
||||
Reference in New Issue
Block a user