Derock
Derock
TtRPC
Created by Derock on 1/13/2024 in #❓-help
is there a way to send a streaming response
it's not much, but pledged $20 to the polar.sh fund for #4477
6 replies
TtRPC
Created by Derock on 1/13/2024 in #❓-help
is there a way to send a streaming response
hopefully this gets finished at somepoint
6 replies
TtRPC
Created by Derock on 1/13/2024 in #❓-help
is there a way to send a streaming response
6 replies
TtRPC
Created by Derock on 11/4/2023 in #❓-help
How to set cookies in trpc response?
@Zeryther / @DxD My solution was the following: inside of the route handler for TRPC, I passed the response headers:
// src/app/api/trpc/trpc/[trpc]
const handler = (req: NextRequest) =>
fetchRequestHandler({
endpoint: "/api/trpc",
req,
router: appRouter,
- createContext: () => createTRPCContext
+ createContext: ({ resHeaders }) => createTRPCContext({ req, resHeaders }),
});
// src/app/api/trpc/trpc/[trpc]
const handler = (req: NextRequest) =>
fetchRequestHandler({
endpoint: "/api/trpc",
req,
router: appRouter,
- createContext: () => createTRPCContext
+ createContext: ({ resHeaders }) => createTRPCContext({ req, resHeaders }),
});
and then updated createTRPCContext to store the resHeaders in the context, and in my tRPC routes I was able to access that and set the cookie using
ctx.resHeaders.set("Set-Cookie", `sessionToken=${token}; Expires=${expire.toUTCString()}; Path=/; HttpOnly; SameSite=Strict`);
ctx.resHeaders.set("Set-Cookie", `sessionToken=${token}; Expires=${expire.toUTCString()}; Path=/; HttpOnly; SameSite=Strict`);
Lastly, the template I used (t3-app) uses unstable_httpBatchStreamLink by default. Setting headers is not supported in this, so I had to use a splitLink so that my auth requests would use httpLink instead.
11 replies
TtRPC
Created by Derock on 11/4/2023 in #❓-help
How to set cookies in trpc response?
i have a solution but i am currently in a class. i will let you know how i fixed it later today
11 replies
TtRPC
Created by Derock on 11/11/2023 in #❓-help
Is it possible to only use WebSockets when necessary, otherwise use httpbatch or http?
but looks like it was never merged
15 replies
TtRPC
Created by Derock on 11/11/2023 in #❓-help
Is it possible to only use WebSockets when necessary, otherwise use httpbatch or http?
dunno what happened to that PR
15 replies
TtRPC
Created by Derock on 11/11/2023 in #❓-help
Is it possible to only use WebSockets when necessary, otherwise use httpbatch or http?
nevermind
15 replies
TtRPC
Created by Derock on 11/11/2023 in #❓-help
Is it possible to only use WebSockets when necessary, otherwise use httpbatch or http?
turns out there's a lazy mode
15 replies
TtRPC
Created by Derock on 11/11/2023 in #❓-help
Is it possible to only use WebSockets when necessary, otherwise use httpbatch or http?
found this!
15 replies
TtRPC
Created by Derock on 11/11/2023 in #❓-help
Is it possible to only use WebSockets when necessary, otherwise use httpbatch or http?
it opens a ws on page load, even if it's not needed
15 replies
TtRPC
Created by Derock on 11/11/2023 in #❓-help
Is it possible to only use WebSockets when necessary, otherwise use httpbatch or http?
it does
15 replies
TtRPC
Created by Derock on 11/11/2023 in #❓-help
Is it possible to only use WebSockets when necessary, otherwise use httpbatch or http?
will splitLink keep an open WS even if it's not needed?
15 replies
TtRPC
Created by Derock on 11/11/2023 in #❓-help
Is it possible to only use WebSockets when necessary, otherwise use httpbatch or http?
thanks
15 replies
TtRPC
Created by Derock on 11/11/2023 in #❓-help
Is it possible to only use WebSockets when necessary, otherwise use httpbatch or http?
will look into that
15 replies
TtRPC
Created by Derock on 11/11/2023 in #❓-help
Is it possible to only use WebSockets when necessary, otherwise use httpbatch or http?
ooh did not know that existed
15 replies
TtRPC
Created by cadams on 11/1/2023 in #❓-help
When error in tRPC route, the error message is vauge
No description
12 replies