shmookoffS
tRPC2y ago
5 replies
shmookoff

react-query no cookies on initial load

Using react-query client on a page that uses router server caller, when initially loading that page, react-query client does not pass cookies through.

Here is a minimal reproduction repo, created with create-t3-app: https://github.com/Shmookoff/trpc-react-query-no-cookies-on-initial-load
1.
Cookie
test
is set in the middleware.
2.
The
/
page is invoking a procedure using server caller.
3.
The
ClientComponent
is invoking a procedure using react-query client.
4.
After the cookie is already set, on initial page load, the
ClientComponent
invokes a procedure without passing the cookie with the request (
{ testCookie: undefined }
in console output).
5.
At this point, the page is fully sent to the client (
 GET / 200 in 151ms
)
6.
The procedure (for some reason) is then invoked the second time, the cookie is present (
{ testCookie: { name: 'test', value: 'test' } }
)
GitHub
Contribute to Shmookoff/trpc-react-query-no-cookies-on-initial-load development by creating an account on GitHub.
GitHub - Shmookoff/trpc-react-query-no-cookies-on-initial-load
Was this page helpful?