Direct communication with external API
See original GitHub issueThe main idea is getting a shorter path to API from SSR and CSR without extra hops and proxies.
For that, we should have different server URLs and client URLs for the same resource ID. Even now you can have different URLs for fetch
between server and client but our serialization system detect resource by the whole URL and produce double request in that situation.
This feature request is not something new and several times accrued in Sapper tracker for example https://github.com/sveltejs/sapper/issues/489
Also, I did some rouge PR for this here https://github.com/sveltejs/kit/pull/1406, and you can find some extra details there.
It looks like we should more detail describe this feature and cases to make a clean solution.
It’s a little confusing theme, but I want to hear your opinions and ideas.
Issue Analytics
- State:
- Created 2 years ago
- Comments:18 (18 by maintainers)
Top GitHub Comments
There’s an issue around browser-sent request headers here: https://github.com/sveltejs/kit/issues/696. I think what we’d need to do here is take the initial
info, init
and normalise them into aRequest
object that includes whichever request headers we decide to include.So perhaps the interface is actually more like this, which conveniently deals with the footgun mentioned above:
Oh, the custom
fetch
replacement idea is really interesting. Lots of flexibility there. I would maybe suggest this interface:There’s no need to pass
fetch
in as it’s globally available inside a SvelteKit app (along withResponse
,Request
andHeaders
).