Skip to content

Commit

Permalink
fix edge runtime errors reading formData and jsonData from request body
Browse files Browse the repository at this point in the history
  • Loading branch information
AirBorne04 committed Jan 24, 2024
1 parent b5573d9 commit ea2e9ce
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions packages/start/config/server-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,18 @@ async function handleServerFunction(h3Event) {
contentType.startsWith("multipart/form-data") ||
contentType.startsWith("application/x-www-form-urlencoded")
) {
parsed.push(await request.formData());
// workaround for https://github.com/unjs/nitro/issues/1721
// (issue only in edge runtimes)
parsed.push(await new Request(request, { ...request, body: event.node.req.body }).formData());
// what should work when #1721 is fixed
// parsed.push(await request.formData);
} else {
parsed = fromJSON(await request.json(), {
// workaround for https://github.com/unjs/nitro/issues/1721
// (issue only in edge runtimes)
const tmpReq = new Request(request, { ...request, body: event.node.req.body })
// what should work when #1721 is fixed
// just use request.json() here
parsed = fromJSON(await tmpReq.json(), {
plugins: [
CustomEventPlugin,
DOMExceptionPlugin,
Expand Down

0 comments on commit ea2e9ce

Please sign in to comment.