T
tRPC

Error in tRPC with Clerk in t3-app router

Error in tRPC with Clerk in t3-app router

CCsarChvz11/10/2023
Hi guys, im trying to implement clerk auth in t3 app router. But it gives me this error when im trying to query: errorrfile: This is my repository link https://github.com/CsarChvz/t3-approuter-clerk-error I mean even
Ssiobe11/10/2023
i've also been having a ton of issues getting clerk to work with trpc in t3 app router, taking a quick look through your repo --- in middleware.ts, i found that you have to add your /api/trpc to the publicRoutes of Clerk's authMiddleware method....sorta like this: authMiddleware({publicRoutes: ["/api/trpc/(.*)"]}) Just posting more of my findings below in the hopes we both can find the solution even after you do that though you'll run into additional authentication issues within the src/server/api/trpc.ts file when trying to implement protectedProcedure's. I find the options are: 1. Use Clerk's auth() method which always returns a userId of null 2. Use Clerk's getAuth() method which you need to pass the req object to. But this also just always returns a userId of null Btw if you try to hit trpc from a client component, it'll work fine no issues. The userId will only return null when you try to access trpc from within rsc's. This makes me think the request object we're getting doesn't have everything we need? idk tho
CCsarChvz11/10/2023
Ty! @siobe I have now the same error about the userId and the userObject:(, null
Ssiobe11/10/2023
Couldn't figure it out tbh, I'm wondering if it's an issue with Clerk's authMiddleware method not fully passing the request through NextResponse to the tRPC route handler in /app/api/trpc/[trpc]/route.ts. But the ppl over at Clerk are definitely smarter than me so it must just be some dumb mistake I can't quite pin down Also some additional info, if you try to use Clerk's getAuth() or auth() methods in an rsc page, it'll work fine there too. Just won't work when trying to use it in the /server/api/trpc file which actually sort of makes sense for the auth() method because it only works when you're in a child of ClerkProvider but with that being said, it should work in the route handler no? Just can't tell if it's my lack of understanding of app router or an actual issue
CCsarChvz11/10/2023
Maybe an issue c: Idk, im asking in clerks discord because it seems weirdc:
Ssiobe11/10/2023
Please let me know if you find out anything 😭
Vvibbin11/10/2023
I'm having the same issues
Ssiobe11/10/2023
This doesn't really solve the issue with Clerk but if anyone wants an alternative I used @supabase/ssr and got auth working. It's a bit more hands on than Clerk in that you have to write your own middleware function

Looking for more? Join the community!

T
tRPC

Error in tRPC with Clerk in t3-app router

Join Server
Recommended Posts
Error when converting string from router.query to prisma DB enumHey yall, I'm working on a Next.js application using tRPC and Prisma, and I've encountered an invaliNext.js tRPC router separated to edge-runtime and node-runtimeI would like to separate server into two runtimes - most things can run on edge-runtime, but I have [How To?] Create a record in database on form submission...I have an application using trpc, Cloudfare D1 database, and trpc. I am trying to use a tamagui forHow to obfuscate data via transformerEnd user with adequate knowledge can easily copy JSON data in plain text from network requests in brResponse delay from TRPC using postgresqlI'm using TRPC as backend and for the database using postgresql so while creating using facing delayCapture TRPCClientError so that it does not show in the client's browser consoleIf a TRPCError is thrown from a router procedure, the client will receive a TRPCClientError that wilNetlify function EMFILEIf this is a dumb question just point me in the direction of the stackoverflow. I've scoured discorempty `input` object when using mutationWhen using `useQuery` I have no issues even with input but when using `useMutation`. The backend is Returning html with TRPCIs it possible to return content-types other than JSON, so HTML for example? I have a requirement thSpecify invalid queries from the server?I have a TRPC app that I am writing and there are times I would like to invalidate queries on the clAutomatically notify about excess queried fields.Hello! Imagine very common situation: We picking "user" with 10 fields, but using only 3 of them in The inferred type of 'trpc' cannot be named without a reference ...Hey everyone, I just changed around the structure of my monorepo where I now have my nextjs applicatrpc mutations for searching dataRecently was told that using mutations to fetch list data is bad. I can agree with this on a high leThe inferred type of 'trpc' cannot be named without a reference. A type annotation is necessary.Hello everybody... I have a nodejs + reactjs + yarn monorepo using turbo. I am getting this error whIs `inferSubscriptionOutput` missing in 10.x?I'm working on a vue 3 app with reactive state and need to infer the output of a subscription. It lis there a way to do client-side "middleware"?My app uses Firebase Auth for authentication. While the user is logged in, they get an ID token whicHow to refetch a call made on the server```js const section = await api.course.getCourseSection.query({ sectionId: parseInt(params.lessoHow to set cookies in trpc response?I have an app dir project that was created using [this t3-app PR](<https://github.com/t3-oss/create-Check if Role is ADMINHey guys I have a private procedure in `T3 Stack`. I need to check if the user thats doing the actioCan middleware be used on a router?Given a router where all procedures need to use the same middleware, can the middleware be somehow a