SSR with initialData throws error
I'm using SSR with Astro and have a client that looks like
It works fine if I create a
But, trying to use SSR with the component and passing the initialData received from the vanilla client throws an error Also, I'm using v11 Also, I know that the initialData is not undefined because I'm rendering it to the screen with Astro
client:only
react component or if I fetch the data with the vanilla client in Astro.But, trying to use SSR with the component and passing the initialData received from the vanilla client throws an error Also, I'm using v11 Also, I know that the initialData is not undefined because I'm rendering it to the screen with Astro
5 Replies
Would it be better if I created a GitHub issue instead?
"Unexpected token U in JSON at position 4" says all you need to know, a malformed message is coming back from the API, which is often more to do with the infrastructure between the client and the api
It's bizarre, since it works fine in development. Are there additional logs or debugging steps I can use to investigate further?
I guess I'm confused because it works great with the vanilla client in an astro component, and works great with a client-only react component. Only when I try to use SSR and initialData with react do I get an error
You’ll need to check the networking between your servers, it’s not really a trpc problem
It works in the two other cases (Astro server component and react client component), so I suspect the issue is with the
The typescript types seems to indicate that I can pass the expected return value of the query as the
initialData
props in the React SSR component.The typescript types seems to indicate that I can pass the expected return value of the query as the
initialData
(which I fetch successfully from the trpc endpoint in the Astro server component), but perhaps I should pass something else like raw response or body? The same exact query works perfectly on the client if I don’t use initialData
I believe the final answer is that initialData should never be undefined, unless using client:only