Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

105
Views
Supabase getUserByCookie not working on mobile

Trying to test my app on a mobile device, but it won't get cookie from server-side requests. (works as expected on chrome) when running getServerSideProps in Next.js I call:

export async function getServerSideProps({ req }) {
  const { user } = await supabase.auth.api.getUserByCookie(req)

  console.log('user from cookie', user)

  if (!user) {
    return { props: {}, redirect: { destination: '/sign-in' } }
  }
  const { data: teams } = await supabase
    .from('teams')
    .select('*')
    .eq('user_id', user.id)

  // do something with the user...
  return {
    props: {
      teams,
    },
  }
}

This returns a user object when I run the app on Chrome or any other web browser, however, when I try on my mobile device, it fails and returns user = null.

I assume this is something related to the cookie session, any advice would be much appreciated.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I once had a problem with cookies and supabase and fixed it by using my service key for the server side code.

create a new client in your supabase client file and export it.

   export const getServiceSupabase = () =>
  createClient(
    process.env.NEXT_PUBLIC_SUPABASE_URL,
    process.env.SUPABASE_SERVICE_KEY
  );

then use this client in your getServerSideProps()

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!