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

259
Vistas
Next JS: getServerSideProps cant get cookie

I want to return two cookies, but only one is returned only token cookie, while key cookie cannot be used

export async function getServerSideProps(ctx) {


 const cookies = ctx.req.headers.cookie;
  const cookie = cookies.split(";");
  const [typeToken, token] = cookie[0].split("=");
  const [typeKey, key] = cookie[1].split("=");

  console.log(token); //Work
  console.log(key); //Work

  return { props: { token, key } };
}

in getServerSide function, it can take the key cookie, but

export default function Index({ token, key }) {
  console.log(token); //work
  console.log(key); //not work

in this function only get token cookie, and cant get key cookie

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You can't have a prop named key in React, it will be overridden. Name it to something else and you should be able to access it. Read more at reactjs.org/warnings/special-props.html

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