Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

108
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda