You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi everybody,
I'm currently facing issues with my tRPC and supabase setup.
This is my function which supplies a supabase client to my tRPC context based on the resHeaders and the request tRPC provides when creating a context:
exportasyncfunctioncreateTRPCSupabaseClient(trpcOptions: FetchCreateContextFnOptions){returncreateServerClient(process.env.NEXT_PUBLIC_SUPABASE_URL!,process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,{cookies: {getAll(){returngetCookies(trpcOptions.req);},setAll(cookiesToSet){try{cookiesToSet.forEach(({ name, value, options })=>{setCookie(trpcOptions.resHeaders,name,value,options);});}catch{// The `setAll` method was called from a Server Component.// This can be ignored if you have middleware refreshing// user sessions.}},},});}
Now my issue is that the tRPC request is already done and the response is already sent to the server before supabase can set the auth headers. So how can I await that supabase sets the cookies before tRPC responds to the client?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi everybody,
I'm currently facing issues with my tRPC and supabase setup.
This is my function which supplies a supabase client to my tRPC context based on the resHeaders and the request tRPC provides when creating a context:
And this is my WIP login tRPC procedure:
Now my issue is that the tRPC request is already done and the response is already sent to the server before supabase can set the auth headers. So how can I await that supabase sets the cookies before tRPC responds to the client?
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions