Potential pitfall around filterSerializedResponseHeaders
#7027
Nickersoft
started this conversation in
Ideas
Replies: 3 comments 6 replies
|
@Nickersoft How did you set up |
4 replies
|
Trying to implement a fetch call to a paginated api that uses headers Total, Per-Page, I setup the filterSerializedResponseHeaders to work on serverside calls, but the clientside load calls do not get the headers back. |
2 replies
|
I had the same problem with my response headers in page load function. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Hey SK folks,
Just wanted to start a discussion regarding the
filterSerializedResponseHeadersoption, as I just spent the better part of the last week trying to chase down why my code wasn't working 😅 Like many other devs, I've been using URQL to call GraphQL in my app, and have quite a few server-side queries I use to pre-render pages. Something I didn't realize, however, is that with most GraphQL clients, receiving anything from the server that isn't ofcontent-typeapplication/jsonis interpreted as an error by the client. By default, SvelteKit doesn't serialize any headers during SSR, which causes the rehydration of my GraphQL queries to havecontent-typetext/plain(the default content type ofnew Response()) and leads to a crash of my page.It wasn't until I added breakpoints throughout SvelteKit's
fetchimplementation that I realized what was going on and stumbled acrossfilterSerializedResponseHeaders. Using this option to whitelistcontent-typein myhandle()method naturally fixed my issue.However, given the plethora of devs who use GraphQL, I can't help but feel this could be a potential pitfall for newcomers to SvelteKit. I wanted to start this thread for a couple of reasons:
content-typeshould be required by SvelteKit apps?I know a lot of folks have said that the SK docs should be improved, and I also know that there's already been some confusion regarding getting empty response headers on page rehydration. So I'm curious how everyone feels about all this.
Thanks! Looking forward to 1.0 🚀
All reactions