Changes
Co-authored-by: renee-png <262607627+renee-png@users.noreply.github.com>
This commit is contained in:
co-authored by
renee-png
parent
2a6a6e4d94
commit
b6233ade1b
@@ -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}` } : {},
|
||||
})
|
||||
},
|
||||
)
|
||||
Reference in New Issue
Block a user