nvegater
nvegater
TTCTheo's Typesafe Cult
Created by nvegater on 11/5/2023 in #questions
Session exists in server component, not in trpc context.
I found the issue. The initial setup of t3 scaffold from the time I started the project (23/10/2023) for the api Proxy client was: headers() { const heads = new Map(headers()); heads.set("x-trpc-source", "rsc"); return Object.fromEntries(heads); }, Now is: headers() { return { cookie: cookies().toString(), "x-trpc-source": "rsc", }; },
5 replies
TTCTheo's Typesafe Cult
Created by nvegater on 11/5/2023 in #questions
Session exists in server component, not in trpc context.
oh no :/, I will try to compare the code in more detail.
5 replies
TTCTheo's Typesafe Cult
Created by nvegater on 10/12/2023 in #questions
How to invalidate trpc queries in Next13
I also tried but I wasn't able to nailed it. I'm impressed 😄 thanks a lot!
10 replies
TTCTheo's Typesafe Cult
Created by nvegater on 10/12/2023 in #questions
How to invalidate trpc queries in Next13
and how can I mark your answer as the answer to this question 😄
10 replies
TTCTheo's Typesafe Cult
Created by nvegater on 10/12/2023 in #questions
How to invalidate trpc queries in Next13
that worked!! thanks a lot! ... I'm curious, how did you know and where can I learn more about this topic ? 😄
10 replies
TTCTheo's Typesafe Cult
Created by nvegater on 10/12/2023 in #questions
How to invalidate trpc queries in Next13
Do you think the forwarded headers are correct?
10 replies
TTCTheo's Typesafe Cult
Created by nvegater on 10/12/2023 in #questions
How to invalidate trpc queries in Next13
the relevant part regarding your suggestion: headers() { // Forward headers from the browser to the API return { ...Object.fromEntries(headers()), "x-trpc-source": "rsc", }; },
10 replies
TTCTheo's Typesafe Cult
Created by nvegater on 10/12/2023 in #questions
How to invalidate trpc queries in Next13
Good point, this is how I configure my trpc client: "use server"; import { getUrl, transformer } from "./shared"; import { httpBatchLink, httpLink, loggerLink, splitLink } from "@trpc/client"; import { experimental_createTRPCNextAppDirServer } from "@trpc/next/app-dir/server"; import { headers } from "next/headers"; import { type AppRouter } from "~/server/api/root"; import fetchPonyfill from "fetch-ponyfill"; export const api = experimental_createTRPCNextAppDirServer<AppRouter>({ config() { return { transformer, links: [ loggerLink({ enabled: (op) => process.env.NODE_ENV === "development" || (op.direction === "down" && op.result instanceof Error), }), splitLink({ condition(op) { // check for context property skipBatch return op.context.skipBatch === true; }, // when condition is true, use normal request true: httpLink({ // vercel issue with fetch undici fetch: fetchPonyfill().fetch, url: getUrl(), }), // when condition is false, use batching false: httpBatchLink({ fetch: fetchPonyfill().fetch, url: getUrl(), headers() { // Forward headers from the browser to the API return { ...Object.fromEntries(headers()), "x-trpc-source": "rsc", }; }, }), }), ], }; }, });
10 replies
TTCTheo's Typesafe Cult
Created by chip on 2/27/2023 in #questions
[next-auth] Updating user model with new values after oauth signin
I read your post 3 times and I couldn't understand what you're trying to accomplish. Maybe if you give more context or explain it in a simpler way? Maybe some Pseudo code ?
4 replies
TTCTheo's Typesafe Cult
Created by nvegater on 2/9/2023 in #questions
Authentication in Websockets
I think I will ask a new question with more context, since this one was a bit incomplete, and your answers are already answering what I asked 🙂 thanks!
13 replies
TTCTheo's Typesafe Cult
Created by nvegater on 2/9/2023 in #questions
Authentication in Websockets
Thank you, same as what I told to @LeoRoese this is in the context of only one tRPC server that runs both the http and the ws connections.... this means that I would like to do this in the createContext function of the tRPC handlers. But technically your answer is correct to how I express my question. Thats an efficient way of doing auth with WS and JWT tokens 🙂 thanks!
13 replies
TTCTheo's Typesafe Cult
Created by nvegater on 2/9/2023 in #questions
Authentication in Websockets
Thank you for your answer 🙂 The ticket message is indeed the best alternative - I should've elaborate my question a bit more since this is in the context of only one tRPC server that runs both the http and the ws connections. The ticket System is only possible with the ws and the http server being separated. But you're right!
13 replies