-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Description
Describe the bug
As of version 1.0.0-next.151
, request.body
in the handle
hook was nullish when the request had no body and was sent via load
's fetch
during SSR from some page.
As of version 1.0.0-next.152
(#2215), it is now Uint8Array(0) []
.
This is inconvenient when you want your handle
hook to call fetch
to proxy some requests, as you can no longer pass the request
object as the second argument to fetch
.
Reproduction
Starting from the sample app, update the handle
hook as so:
export const handle = async ({ request, resolve }) => {
console.log(request.body);
// ...
};
Navigate to the /todos
page (which makes API calls), and hit refresh to get a server-rendered page.
Logs
(in the above repro)
Uint8Array(0) []
(in my app)
Request with GET/HEAD method cannot have body
TypeError: Request with GET/HEAD method cannot have body
at new Request (file:///foo/node_modules/@sveltejs/kit/dist/install-fetch.js:1254:10)
System Info
System:
OS: Linux 5.10 Debian GNU/Linux 10 (buster) 10 (buster)
CPU: (8) x64 Intel(R) Core(TM) i7-10510U CPU @ 1.80GHz
Memory: 5.92 GB / 12.32 GB
Container: Yes
Shell: 5.0.3 - /bin/bash
Binaries:
Node: 14.17.5 - /usr/local/bin/node
Yarn: 1.22.5 - /usr/local/bin/yarn
npm: 6.14.14 - /usr/local/bin/npm
npmPackages:
@sveltejs/adapter-node: next => 1.0.0-next.43
@sveltejs/kit: 1.0.0-next.152 => 1.0.0-next.152
svelte: 3.42.3 => 3.42.3
Severity
serious, but I can work around it
Additional Information
We've previously blessed calling fetch
in handle
as a way to deal with API calls in SSR where the app server and the API server live in different places, but are both behind the same reverse proxy when seen from a browser.