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

204
Views
Tipo de sesión en getServerSideProps en NextJS con next-auth

Estoy implementando la página del tablero con flujo de credenciales con NextJS y next-auth, tengo un tipo de sesión aumentado en next-auth.d.ts según los documentos https://next-auth.js.org/getting-started /typescript#module-aumentation así

 import NextAuth from "next-auth"; declare module "next-auth" { interface Session extends NextAuth.DefaultSession { user: { id: string; email: string; }; } }

y funciona como se esperaba en todas partes del lado del cliente. Ahora necesito obtener los datos de la sesión en los accesorios de getServerSide, así que sigo este ejemplo https://next-auth.js.org/configuration/nextjs#unstable_getserversession y, aunque debería obtener el tipo que configuré, obtengo el tipo de sesión predeterminada original que es

 export interface DefaultSession extends Record<string, unknown> { user?: { name?: string | null; email?: string | null; image?: string | null; }; expires: ISODateString; }

y obtengo errores porque intenta clasificar los elementos indefinidos en el nombre y la imagen y cuando intento iniciar sesión en el lado del servidor session.id en los accesorios GetServerSide, obtengo undefined.

Este es mi GetServerSideProps:

 export const getServerSideProps: GetServerSideProps = async (context) => { const session = await unstable_getServerSession( context.req, context.res, authOptions ); if (!session) { return { redirect: { destination: "/", permanent: false, }, }; } return { props: {}, // will be passed to the page component as props }; };

Gracias por cualquier ayuda

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!