-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Description
Describe the bug
In a load function of a page, doing a fetch to http://localhost:3000/api will throw an error:
Request with GET/HEAD method cannot have body.Here is the code:
const resultPOST = await event.fetch("http://localhost:3000/api", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
hello: "World",
}),
});
const jsonPOST = await resultPOST.json();Info
I stripped down the reproduction to http://localhost:3000/api URL.
But my use case will be to target other APIs not only locals one like '/api'
Reproduction
Here is the stackblitz: https://stackblitz.com/fork/github/jycouet/sk-359-post
(fetch issue is happening, but the log is different than locally!)
Here is the minimal repo: https://github.com/jycouet/sk-359-post
With the few step in git from npx create to the issue.
Logs
Request with GET/HEAD method cannot have body.
TypeError: Request with GET/HEAD method cannot have body.
at new Request (file:///home/jycouet/udev/tmp/sk-359-post/node_modules/@sveltejs/kit/dist/node/polyfills.js:9104:14)
at Agent$1.fetch (file:///home/jycouet/udev/tmp/sk-359-post/node_modules/@sveltejs/kit/dist/node/polyfills.js:10280:22)
at fetch (file:///home/jycouet/udev/tmp/sk-359-post/node_modules/@sveltejs/kit/dist/node/polyfills.js:12200:22)
at Object.fetch (file:///home/jycouet/udev/tmp/sk-359-post/.svelte-kit/runtime/server/index.js:2293:51)
at load (index.svelte:17:35)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async load_node (file:///home/jycouet/udev/tmp/sk-359-post/.svelte-kit/runtime/server/index.js:2394:12)
at async respond$1 (file:///home/jycouet/udev/tmp/sk-359-post/.svelte-kit/runtime/server/index.js:2778:15)
at async resolve (file:///home/jycouet/udev/tmp/sk-359-post/.svelte-kit/runtime/server/index.js:3291:11)System Info
System:
OS: Linux 5.4 Ubuntu 20.04.2 LTS (Focal Fossa)
CPU: (8) x64 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
Memory: 1.24 GB / 7.69 GB
Container: Yes
Shell: 5.0.17 - /bin/bash
Binaries:
Node: 16.15.1 - ~/.volta/tools/image/node/16.15.1/bin/node
Yarn: 1.22.17 - ~/.volta/tools/image/yarn/1.22.17/bin/yarn
npm: 8.3.0 - ~/.volta/tools/image/npm/8.3.0/bin/npm
npmPackages:
@sveltejs/adapter-auto: next => 1.0.0-next.53
@sveltejs/kit: 1.0.0-next.359 => 1.0.0-next.359
svelte: ^3.44.0 => 3.48.0
vite: 2.9.13 => 2.9.13Severity
blocking an upgrade
Additional Information
It's a blocker for our Library Houdini that was working well before next.359.
We have an issue open here: HoudiniGraphql/houdini#374
Nickersoft, dsaket, philipdanielhayton, MathiasWP, spences10 and 1 more
Metadata
Metadata
Assignees
Labels
No labels