shmookoff
Explore posts from serversreact-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' } }
)6 replies
DTDrizzle Team
•Created by shmookoff on 6/22/2024 in #help
Zod table+field descriptor generic schema
I'm building a tRPC procedure for listing rows from a table.
I want the user to control the ordering of result by supplying an array of objects with table and the corresponding column name.
This works:
I wanted to create a generic function for constructing the descriptor schema based on provided table:
However, I've stumbled upon the following error:
Which (I think) is related to this.
Any help would be greately apprecieated, as I'm really stuck at this...
1 replies
DTDrizzle Team
•Created by shmookoff on 6/4/2024 in #help
Run migrations inside of a Docker container
I have a dockerized Next.js application. The image only contains built application (
dist
folder).
I want to be able to run migrations from within running application container.
My first thought was to create a migration script using the example from docs - https://orm.drizzle.team/docs/migrations and compile it at image building stage. However, I don't have enough experience with tsc
to accomplish the goal.
I don't want to use tsx
as this would add complexity to the image (eg. copy all of the dependencies for db.ts
) .
How would you accomplish this?1 replies
TTCTheo's Typesafe Cult
•Created by shmookoff on 2/28/2024 in #questions
How does NextAuth persist session cookie in t3 stack
In an app created with create-t3-app, NextAuth is set up without the use of Next middlewares.
From my experience using Next with App Dir, a cookie can only be set server-side in a middleware or in a route handler. As said earlier, there are no NextAuth middlewares in created project, nor does NextAuth use a route handler to persist a session (eg. refresh session token).
The only NextAuth entrypoint in project is
getServerAuthSession
call in createTRPCContext
.
Furthermore, tRPC is setup to use unstable_httpBatchStreamLink
which streams the response (same streaming RSC), so you can't set a cookie with tRPC.
After thinking a bit,
probably, createTRPCContext
is run prior to sending the initial response. This is the only way I could imagine this works.
https://trpc.io/docs/server/context suggests that createTRPCContext
is run "for each invocation of tRPC". However, that does not suggest that it is run prior to sending the initial response.
Am I right? What am I missing here? Where can I find relevant documentation?3 replies