-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Content-Type for responses with sveltes fetch always text/plain on client #7112
Comments
This sounds extremely similar to #6412. Can you clarify the differences between the two? |
in 6412 it sounded like it happens when using server.js file and netlify-adapter only on production. for me it happens for adapter-node and on the client side of the +page.js file - its very similar but not quite completely. Reproducing my case above is easier as it happens locally |
This happens only during initial hydration, i.e. the server produces the SSR and then /** @type {import('@sveltejs/kit').Handle} */
export function handle({ event, resolve }) {
return resolve(event, {
// you can also seralize other headers here if needed
filterSerializedResponseHeaders: (name, value) => name === 'content-type'
});
} This is also mentioned here in the docs: https://kit.svelte.dev/docs/load#input-methods-fetch That said, I'm wondering how to make this error more discoverable, and if it makes sense to have some subset of serialized response headers by default. cc @Conduitry @Rich-Harris who might have an opinion on this. In #6569 where it was implemented this exact case was discussed, and it looks like it added some code to surface this error - so now I'm wondering why that error isn't triggered here. Update: That check was moved in #7113 and seems to no longer work now. |
thank you very much, that actually fixed it. i would have never found this myself in the docs. |
* [fix] ensure serialized headers check is always applied Closes #7112 * fix test, add check only when client side rendering enabled
Describe the bug
I am fetching ressources from a database on the same server (also happening on localhost) and after migrating to latest svelte-kit (before was version next.3xxx) i observe there is a difference in the headers between server and client fetch.
Unfortunately i need to check the headers and call res.json reps. res.text accordingly and this is not working anymore.
Reproduction
i tried to recreate this on stackblitz but get CORS issues (see https://stackblitz.com/edit/sveltejs-kit-template-default-uyfzch?file=src/routes/test/+page.js)
however locally you can easily test it by doing this:
Logs
No response
System Info
Severity
blocking all usage of SvelteKit
Additional Information
No response
The text was updated successfully, but these errors were encountered: