Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

106
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda