T
tRPC

Async User Call in `createContext` (context.ts) or in `isAuthed` (in trpc.ts)

Async User Call in `createContext` (context.ts) or in `isAuthed` (in trpc.ts)

Ssb4/4/2023
Hi all! Should I be getting the user in all requests via createContext in the following async call
const { user } = await supabaseAdmin.auth.api.getUserByCookie(opts.req)
const { user } = await supabaseAdmin.auth.api.getUserByCookie(opts.req)
Or would it be more sensible for this to only be called in certain procedures such as middleware like isAuthed? In theory, I don't want public API calls being slower because of the delay it takes to fetch the user. (we use NextJS if relevant)
Ssb4/4/2023
How does this look?
Nnlucas4/5/2023
Whichever works for you They’re both fine

Looking for more? Join the community!

T
tRPC

Async User Call in `createContext` (context.ts) or in `isAuthed` (in trpc.ts)

Join Server