siobe
siobe
TtRPC
Created by entropy on 5/25/2023 in #❓-help
Issue with trpc fetch when trying to pass Clerk auth to context
i couldn't get it to work when i passed opt.req to auth() or to getAuth()
53 replies
TtRPC
Created by entropy on 5/25/2023 in #❓-help
Issue with trpc fetch when trying to pass Clerk auth to context
here's a working repo but uses cookies from opts to verify the session rather than the getAuth method
53 replies
TtRPC
Created by entropy on 5/25/2023 in #❓-help
Issue with trpc fetch when trying to pass Clerk auth to context
53 replies
TtRPC
Created by SansPapyrus683 on 11/13/2023 in #❓-help
`useQuery` not working?
Here, give this should explain it: https://www.youtube.com/watch?v=PmBfq-SpzCU
14 replies
TtRPC
Created by SansPapyrus683 on 11/13/2023 in #❓-help
`useQuery` not working?
Yes
14 replies
TtRPC
Created by SansPapyrus683 on 11/13/2023 in #❓-help
`useQuery` not working?
And also you can't use hooks inside rsc, so it'd just fail on that account
14 replies
TtRPC
Created by SansPapyrus683 on 11/13/2023 in #❓-help
`useQuery` not working?
Theo's vid on the app router release for t3 explains it
14 replies
TtRPC
Created by SansPapyrus683 on 11/13/2023 in #❓-help
`useQuery` not working?
Only applies if you're using t3 with app router: If you're trying to use API in a client component then API needs to be imported from /trpc/react If you're using API in an rsc or anything on the server, you import from /trpc/server
14 replies
TtRPC
Created by SansPapyrus683 on 11/13/2023 in #❓-help
`useQuery` not working?
Are you using t3 stack? Make sure you're importing API from the correct file if you're using app router
14 replies
TtRPC
Created by Vengeance on 11/10/2023 in #❓-help
useQuery in App Router?
where are you importing api from? You have to make sure you import it from /trpc/react.ts
8 replies
TtRPC
Created by CsarChvz on 11/10/2023 in #❓-help
Error in tRPC with Clerk in t3-app router
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
10 replies
TtRPC
Created by CsarChvz on 11/10/2023 in #❓-help
Error in tRPC with Clerk in t3-app router
Please let me know if you find out anything 😭
10 replies
TtRPC
Created by CsarChvz on 11/10/2023 in #❓-help
Error in tRPC with Clerk in t3-app router
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
10 replies
TtRPC
Created by CsarChvz on 11/10/2023 in #❓-help
Error in tRPC with Clerk in t3-app router
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
10 replies
TtRPC
Created by CsarChvz on 11/10/2023 in #❓-help
Error in tRPC with Clerk in t3-app router
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
10 replies
TtRPC
Created by Thimo_o on 8/26/2023 in #❓-help
How do I setup App router + TRPC + Lucia Auth? (protected routes)
"But the session is not passed into ctx resulting in always getting the unauthorized error. Does someone know what I did wrong to make this work?" I'm running into the exact same issue trying to get Clerk working with app router (Theo's Chirp video showed it working in pages router, not in app router). How did you manage to get the ctx to pass the request with the auth info in this line: const session = await getDefaultSession(req) With Clerk I'm trying to get the auth session with const auth = getAuth(req) and it always returns null
7 replies
TtRPC
Created by entropy on 5/25/2023 in #❓-help
Issue with trpc fetch when trying to pass Clerk auth to context
i'm new here so sorry if i'm asking in the wrong place, but did this code snippet work for you when using the app router or pages router? been trying to implement Clerk authentication with t3 using the app router and running into issues with Clerk's getAuth() and auth() methods both returning null for auth specifically in this line: auth: getAuth(req), in the createInnerTRPCContext method
53 replies