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

260
Views
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 answers
Answer question

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 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!