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

184
Views
¿Reaccionar NextJS getServerSideProps no funciona?

Mientras estaba haciendo un discord oauth2, quería guardar los datos en la próxima sesión de hierro.

req.session.set("user", ...data) y se guardó cuando lo verifiqué. Ahora el problema está en getServerSideProps .

Este es mi código TSX getServerSideProps

 export const getServerSideProps: GetServerSideProps = withSession(unauthenticatedRoute);

Este es el código de la sesión.

 import { withIronSession } from "next-iron-session"; import { NextIronHandler, NextRoute } from "../typings/types"; export function withSession(handler: NextIronHandler | NextRoute) { return withIronSession(handler, { password: process.env.COOKIE_SECRET, cookieName: "session", ttl: 15 * 24 * 3600, cookieOptions: { secure: process.env.NODE_ENV === "production", sameSite: "strict", httpOnly: true, }, }); }

Y este es el código de ruta.

 export async function unauthenticatedRoute( ctx: GetServerSidePropsContext & { req: { session: Session } } ) { const user = ctx.req.session.get("user"); return { props: user ? { user } : {}, }; }

cuando usaba

 function HomePage({ user }: Props) { const router = useRouter(); useEffect(() => { if (router.query.r) { location.replace("/"); } console.log(user) }, []); }

Se registró undefined , ¿alguien sabe por qué?

about 4 years ago · Juan Pablo Isaza
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!