Skip to content
5 changes: 5 additions & 0 deletions .changeset/breezy-poets-grow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

fix: clone `fetch` responses so that headers are mutable
5 changes: 4 additions & 1 deletion packages/kit/src/runtime/server/respond.js
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,10 @@ export async function internal_respond(request, options, manifest, state) {

// we can't load the endpoint from our own manifest,
// so we need to make an actual HTTP request
return await fetch(request);
const response = await fetch(request);

// clone the response so that headers are mutable (https://github.com/sveltejs/kit/issues/13857)
return new Response(response.body, response);
} catch (e) {
// TODO if `e` is instead named `error`, some fucked up Vite transformation happens
// and I don't even know how to describe it. need to investigate at some point
Expand Down