Use differentiate server and client url.
oexza opened this issue · 3 comments
Describe the bug
I have a sveltekit app that runs on the same node as the graphql server. When you specify the URL as say https://mygqlserver.com
it is fine on the client side, but on the server side during SSR it implies that HoudiniClient makes a call over the internet which is routed right back to the same node running the graphql server, when it should have been a simple http://locahost:PORT call. I propose the HoudiniClient accepts two URLs, server and client. This change would be unnecessary for Subscriptions since that runs only on the client.
Severity
annoyance
Steps to Reproduce the Bug
Issue is obvious. No nee for a reproduction.
Reproduction
No response
You could probably do thing on your side? With something like this:
import { HoudiniClient } from '$houdini'
import { browser } from '$app/environment'
export default new HoudiniClient({
url: `http://${(browser ? 'pc' : 'api')}:3000/graphql`,
})
Let us know if it fits your needs.
Thanks @jycouet . I already tried that, it doesn't work. Once the url is set during SSR, it doesn't change on the client.
I think the best way to pull this off is with a custom plugin. The default fetch plugin just uses client.url
but you can define your own to use whatever values you want.