Post request via fetch gets overriden/replaced in `load()`
See original GitHub issueDescribe the bug Two parallel (?) fetch POST requests (one from $layout.svelte, and one from index.svelte) with different contents end up having the same response on the client side.
Logs nothing interesting happening in the logs
To Reproduce I set up a repro repository here https://github.com/neesh-studio/sk-fetch-override-repro which loads two festival objects from a graphQL api. One Festival is called “First Festival”, the other “Another Festival”.
The SSR implementation seems to work as there is a short flash of the “Another Festival” title on page refresh. But it get’s replaced on the client with “First Festival”.
What i get to see:

Expected behavior
what I expect to see:

I expect the fetch api to work the same on server and client and the client not overriding another (POST) request. (A quick test shows the behaviour seems fine for GET requests)
The problem goes away if I uncomment line 21 in api.ts
if (typeof window !== "undefined") fetchApi = fetch;
Information about your SvelteKit Installation:
- The output of
npx envinfo --system --npmPackages svelte,@sveltejs/kit --binaries --browsers
System:
OS: Linux 5.4 Ubuntu 20.04.2 LTS (Focal Fossa)
CPU: (4) x64 Intel(R) Core(TM) i5-3320M CPU @ 2.60GHz
Memory: 10.16 GB / 12.35 GB
Container: Yes
Shell: 5.0.17 - /bin/bash
Binaries:
Node: 14.15.5 - ~/.nvm/versions/node/v14.15.5/bin/node
npm: 6.14.11 - ~/.nvm/versions/node/v14.15.5/bin/npm
npmPackages:
@sveltejs/kit: next => 1.0.0-next.58
svelte: ^3.29.0 => 3.35.0
-
Your browser Chrome: Version 89.0.4389.90 (64-Bit)
-
Your adapter (e.g. Node, static, Vercel, Begin, etc…) dev server
Severity Minor, there is a workaround (as described) but I wanted to post the issue early in case this is somehow connected to #591
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:9 (9 by maintainers)

Top Related StackOverflow Question
In any case, I don’t think it’s safe to assume that two requests with different POST bodies would have the same response anyway, even if they happened to be JSON encodings of equivalent objects. That sounds like a place we don’t want to go.
Possibly… though I don’t think there’s a good reason anyone would have for POSTing to anything that wasn’t a GraphQL endpoint in
load