Skip to content

how to getSession with serverSupabaseClient? #205

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
stlbucket opened this issue Jul 18, 2023 · 4 comments
Closed

how to getSession with serverSupabaseClient? #205

stlbucket opened this issue Jul 18, 2023 · 4 comments
Labels
question Further information is requested Stale

Comments

@stlbucket
Copy link

Is there another header I need to provide in order for serverSupabaseClient to find a session?

I have the following server middleware:

import { serverSupabaseClient } from '#supabase/server'

export default eventHandler(async (event) => {
  const client = serverSupabaseClient(event)

  const { data } = await client.auth.refreshSession()
  console.log('headers', event.node.req.headers)
  console.log('CLIENT SESSION', data)
})

my output always looks like this:

headers {                                                                                                                                                6:59:02 PM
  'sec-fetch-site': 'same-origin',
  'sec-fetch-mode': 'cors',
  'sec-fetch-dest': 'empty',
  cookie: 'sb-access-token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJhdXRoZW50aWNhdGVkIiwiZXhwIjoxNjg5NjQ5MDc3LCJzdWIiOiJlZjlmMzM3Yy05N2Y3LTRiOWYtYmI1Zi04ZjRlMWQ2OTY4ZDEiLCJlbWFpbCI6ImFwcC1hZG1pbi1zdXBlckBleGFtcGxlLmNvbSIsInBob25lIjoiIiwiYXBwX21ldGFkYXRhIjp7InByb3ZpZGVyIjoiZW1ha..............truncated',
CLIENT SESSION { user: null, session: null }                                                                                                             6:59:02 PM
...
}

i can manually parse the cookie down the chain.

@stlbucket stlbucket added the question Further information is requested label Jul 18, 2023
@stlbucket
Copy link
Author

i believe i am simply confused thinking that the cookie just needs to be there, and not each piece of it as a separate header:

https://supabase.nuxtjs.org/usage/services/server-supabase-client

useRequestHeaders(['cookie'])

should fix this for me, yes? i am using the nuxt-graphql-client, so I think this may be my real question:

Diizzayy/nuxt-graphql-client#343

@stlbucket
Copy link
Author

stlbucket commented Jul 18, 2023

actually no. i was able to add cookie headers to my request (on first call. still maybe a dependency on the other issue):

  'sb-refresh-token': 'OpuhlJ6B.......',
  'sb-access-token': 'eyJhbGciOiJIU........',

still no values being returned for getSession or refreshSession

Copy link

github-actions bot commented May 6, 2025

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 github-actions bot added the Stale label May 6, 2025
Copy link

github-actions bot commented Jun 5, 2025

This issue was closed because it has been stalled for 30 days with no activity.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jun 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested Stale
Projects
None yet
Development

No branches or pull requests

1 participant