Skip to content

Commit

Permalink
Merge pull request #1282 from AirBorne04/main
Browse files Browse the repository at this point in the history
fix edge runtime errors reading formData and jsonData from request body
  • Loading branch information
ryansolid authored Jan 24, 2024
2 parents 24a4eb2 + 92e8f8f commit c4de61d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/neat-apricots-try.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@solidjs/start": patch
---

fix formData and action issue for cloud runtimes
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 c4de61d

Please sign in to comment.