Skip to content

Commit

Permalink
fix: handle Buffer in readBody
Browse files Browse the repository at this point in the history
  • Loading branch information
johannschopplich committed Mar 24, 2023
1 parent ba64f60 commit ae1f91d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/utils/body.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,12 @@ export async function readBody<T = any>(event: H3Event): Promise<T> {
return (event.node.req as any)[ParsedBodySymbol];
}

// TODO: Handle buffer
const body = (await readRawBody(event)) as string;
let body = (await readRawBody(event)) as string;

// Handle inconsistent `readBody` behavior in some Nitro presets
if (Buffer.isBuffer(body)) {
body = (body as Buffer).toString()
}

if (
event.node.req.headers["content-type"] ===
Expand Down

0 comments on commit ae1f91d

Please sign in to comment.