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

216
Views
NextAuth obteniendo el punto final de API - req.body indefinido

Estoy tratando de usar NextAuthJS para la autenticación en mi aplicación NextJS.

Estoy usando este siguiente código de la documentación.

 authorize: async(credentials, req)=>{ const res = await fetch("http://localhost:3000/api/userverify",{ method: 'POST', credentials: "include", body: JSON.stringify(credentials), headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' }, }) const user = await res.json() if(res.ok && user){ return user } return null }

el problema es la obtención real, en userverify.js tengo este código:

 export default async function verify(res, req){ const credentials = req.body console.log(credentials) const user = await findUser(credentials.email) if(user){ if(await argon2.verify(req.body.password, user.password)){ res.status(200).send(user) return user } else{ res.status(401).send("Credentials Incorrect") } } }

req.body en este archivo no está definido, no estoy usando express solo nextjs construido en rutas api.

¿Que puedo hacer?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Creo que es el orden de los argumentos. ¿Intentaste registrar req y res ? El primer argumento es request y el segundo es response :

 export default async function verify(req, res){

Documentos

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!