Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: do not replace headers on fetch requests with error state #13341

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/bright-scissors-grow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

fix: avoid overwriting headers for sub-requests made while loading the error page
10 changes: 5 additions & 5 deletions packages/kit/src/runtime/server/respond.js
Original file line number Diff line number Diff line change
Expand Up @@ -508,11 +508,11 @@ export async function respond(request, options, manifest, state) {
}

if (state.error && event.isSubRequest) {
return await fetch(request, {
headers: {
'x-sveltekit-error': 'true'
}
});
// avoid overwriting the headers. This could be a same origin fetch request
// to an external service from the root layout while rendering an error page
const headers = new Headers(request.headers);
headers.set('x-sveltekit-error', 'true');
return await fetch(request, { headers });
}

if (state.error) {
Expand Down
Loading