Dancamdev
Dancamdev
TTCTheo's Typesafe Cult
Created by Dancamdev on 1/24/2024 in #questions
Exposing Supabase Session to TRPC Server
Hi Matheus. sorry I did not get back to you, I did eventually manage to get it working by using the supabase route handler client instead, which only requires the cookies to be passed in
export const createTRPCContext = async (opts: { headers: Headers }) => {
const supabase = createRouteHandlerClient<Database>({
cookies: () => cookies(),
});

const {
data: { session },
} = await supabase.auth.getSession();

return {
db,
supabase,
session,
...opts,
};
};
export const createTRPCContext = async (opts: { headers: Headers }) => {
const supabase = createRouteHandlerClient<Database>({
cookies: () => cookies(),
});

const {
data: { session },
} = await supabase.auth.getSession();

return {
db,
supabase,
session,
...opts,
};
};
Thanks for the helpful advice!
4 replies