You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If I have a +server.js endpoint that ends in a return fetch(...), this works fine in development, but if during building I attempt to prerender this endpoint's response, I get an error about headers being immutable from within undici. Presumably, SvelteKit is trying to change the response headers that it's getting from the +server.js function, and presumably the Response object that undici returns has had its headers frozen.
Describe the proposed solution
I think SvelteKit, at least when prerendering, should attempt to create a new Response object when it's adding its headers to the response.
Part of me has the potentially bad idea of running all undici responses through the code listed below in 'Alternatives considered'. Presumably someone, if they attempted to mutate such a Response in their handle hook after calling resolve would run into this same issue, even when not prerendering. (I've not actually tested this.) But perhaps at that point it's their responsibility to make sure they're handling this appropriately?
at the bottom of each relevant GET function, which works fine, but it took me a while to figure out what was going on and to arrive at this as a solution.
Importance
nice to have
Additional Information
No response
The text was updated successfully, but these errors were encountered:
Describe the problem
If I have a
+server.js
endpoint that ends in areturn fetch(...)
, this works fine in development, but if during building I attempt to prerender this endpoint's response, I get an error about headers being immutable from within undici. Presumably, SvelteKit is trying to change the response headers that it's getting from the+server.js
function, and presumably theResponse
object that undici returns has had its headers frozen.Describe the proposed solution
I think SvelteKit, at least when prerendering, should attempt to create a new
Response
object when it's adding its headers to the response.Part of me has the potentially bad idea of running all undici responses through the code listed below in 'Alternatives considered'. Presumably someone, if they attempted to mutate such a
Response
in theirhandle
hook after callingresolve
would run into this same issue, even when not prerendering. (I've not actually tested this.) But perhaps at that point it's their responsibility to make sure they're handling this appropriately?Alternatives considered
Right now, I'm running the responses through
at the bottom of each relevant
GET
function, which works fine, but it took me a while to figure out what was going on and to arrive at this as a solution.Importance
nice to have
Additional Information
No response
The text was updated successfully, but these errors were encountered: