Skip to content

Commit 8b2f70a

Browse files
Copilothotlong
andcommitted
fix: convert Buffer to ArrayBuffer for BodyInit compatibility in extractBody
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com> Agent-Logs-Url: https://github.com/objectstack-ai/objectql/sessions/27805a57-b375-4669-81c2-92748708c736
1 parent 0d3c8d3 commit 8b2f70a

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

apps/demo/api/[[...route]].ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,11 @@ function extractBody(incoming: VercelIncomingMessage, method: string, contentTyp
176176
if (method === 'GET' || method === 'HEAD' || method === 'OPTIONS') return null;
177177
if (incoming.rawBody != null) {
178178
if (typeof incoming.rawBody === 'string') return incoming.rawBody;
179-
return incoming.rawBody as unknown as Uint8Array;
179+
// Convert Node.js Buffer to ArrayBuffer — required because the TypeScript lib
180+
// used during Vercel bundling (ES2019 without DOM) only guarantees ArrayBuffer
181+
// in the BodyInit union; Uint8Array is not listed in older lib.dom.d.ts.
182+
const buf = incoming.rawBody;
183+
return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength) as ArrayBuffer;
180184
}
181185
if (incoming.body != null) {
182186
if (typeof incoming.body === 'string') return incoming.body;

0 commit comments

Comments
 (0)