From d8f133cd5aa6ebf493d7afa07cb51eda484650ff Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Mon, 18 May 2026 22:02:39 +0000 Subject: [PATCH] Changes Co-authored-by: domfelipe <53182096+domfelipe@users.noreply.github.com> --- src/integrations/supabase/auth-attacher.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/integrations/supabase/auth-attacher.ts diff --git a/src/integrations/supabase/auth-attacher.ts b/src/integrations/supabase/auth-attacher.ts new file mode 100644 index 0000000..5bc57b7 --- /dev/null +++ b/src/integrations/supabase/auth-attacher.ts @@ -0,0 +1,15 @@ +// This file is automatically generated. Do not edit it directly. +import { createMiddleware } from '@tanstack/react-start' +import { supabase } from './client' + +// Must be registered as a global `functionMiddleware` in `src/start.ts`; otherwise +// the browser never attaches the bearer token to serverFn RPCs. +export const attachSupabaseAuth = createMiddleware({ type: 'function' }).client( + async ({ next }) => { + const { data } = await supabase.auth.getSession() + const token = data.session?.access_token + return next({ + headers: token ? { Authorization: `Bearer ${token}` } : {}, + }) + }, +)