wobsoriano / trpc-nuxt

End-to-end typesafe APIs in Nuxt applications.
trpc-nuxt.vercel.app
MIT License
687 stars 39 forks source link

SSR Context Lost #175

Closed felixSchl closed 3 months ago

felixSchl commented 5 months ago

Hey, I filed a bug earlier today with Nuxt that the $fetch global in useAsyncData loses the SSR event context. It is not a confirmed bug, so maybe it is actually intended behaviour. I am not sure. I saw in the nuxt sources they do this for their useFetch composable: https://github.com/nuxt/nuxt/blob/main/packages/nuxt/src/app/composables/fetch.ts#L172-L178.

Anyway, I think we should pass the fetch object returned from useRequestFetch into the http links. Thankfully this library already lets me override the fetch setting via the opts arg (doesn't type-check though) so I could confirm with this change it retains the SSR context. Should probably be part of the library and default though, hence the report.

wobsoriano commented 4 months ago

Hey, sorry for replying late but I'll do my by best to check this out on the weekend