Description
Describe the bug
When all of these conditions are met:
- SSR request with server-side fetch
- Request initiated from an error page, such as
404
- Request endpoint is on an external backend such as a Golang backend, not a Sveltekit route
The headers of the request are dropped in favor of x-sveltekit-error: true
This issue prevents me from displaying the authenticated user of my app when the user reaches a 404 page for example.
Reproduction
How to reproduce
I have created this repo https://github.com/aureleoules/sveltekit-headers-bug-reproduction
To reproduce:
$ git clone [email protected]:aureleoules/sveltekit-headers-bug-reproduction.git /tmp/repro && cd /tmp/repro
$ npm i
$ npm run dev # in one terminal
$ go run main.go # in another terminal
> http://localhost:5173/
There are two API endpoints, one using the Sveltekit backend in src/routes/sveltekit_route
to show that it works correctly using Sveltekit.
And one in main.go
that shows headers are not passed properly using an external backend.
Both endpoints return the request headers in the response.
Results
Current behavior
On normal page: all headers present (cookie and custom-header)
On error page: missing cookie and custom-header
Expected behavior
Fix in #13341
On normal page: all headers present (cookie and custom-header)
On error page: all headers present (cookie and custom-header)
Logs
System Info
System:
OS: Linux 5.15 Ubuntu 22.04.4 LTS 22.04.4 LTS (Jammy Jellyfish)
CPU: (32) x64 AMD Ryzen 9 7950X 16-Core Processor
Memory: 6.02 GB / 15.20 GB
Container: Yes
Shell: 5.1.16 - /bin/bash
Binaries:
Node: 20.14.0 - /usr/bin/node
Yarn: 1.22.22 - /usr/bin/yarn
npm: 10.7.0 - /usr/bin/npm
pnpm: 9.15.4 - /usr/bin/pnpm
Browsers:
Chrome: 131.0.6778.108
npmPackages:
@sveltejs/adapter-auto: ^4.0.0 => 4.0.0
@sveltejs/adapter-node: ^5.2.12 => 5.2.12
@sveltejs/kit: ^2.0.0 => 2.16.0
@sveltejs/vite-plugin-svelte: ^4.0.0 => 4.0.4
svelte: ^5.0.0 => 5.19.0
vite: ^5.4.11 => 5.4.11
Severity
serious, but I can work around it
Additional Information
No response