supabase icon indicating copy to clipboard operation
supabase copied to clipboard

Refresh token on server

Open franzwarning opened this issue 1 year ago • 2 comments

Quick question -- I'm making api calls on the server which require the supabase access token. My question is: is the token automatically refreshed on the server? Or just the client? I had to add this in my middleware/auth to get it to work (note, just using useSupabaseSession()) wasn't actually refreshing the token.

export default defineNuxtRouteMiddleware(async (to, _from) => {
    const client = useSupabaseClient()

    const session = await client.auth.getSession()

    if (!session.data.session) {
        return navigateTo(
            Urls.SignIn({ redirectAfter: encodeURIComponent(to.fullPath) })
        )
    }
})

franzwarning avatar Apr 22 '24 17:04 franzwarning

Could we potentially add an argument to useSupabaseSession which awaits on refresh token (if necessary)

franzwarning avatar Apr 22 '24 17:04 franzwarning

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 30 days.

github-actions[bot] avatar May 06 '25 13:05 github-actions[bot]