diff --git a/src/utils/body.ts b/src/utils/body.ts index d73b06c4f..8cc333b8d 100644 --- a/src/utils/body.ts +++ b/src/utils/body.ts @@ -28,12 +28,17 @@ export async function readBody< _Event extends HTTPEvent = HTTPEvent, _T = InferEventInput<"body", _Event, T>, >(event: _Event): Promise { + const contentType = event.req.headers.get("content-type") || ""; + + if (contentType.startsWith("multipart/form-data")) + return Object.fromEntries(await event.req.formData()) as _T; + const text = await event.req.text(); + if (!text) { return undefined; } - const contentType = event.req.headers.get("content-type") || ""; if (contentType.startsWith("application/x-www-form-urlencoded")) { return parseURLEncodedBody(text) as _T; }