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

804
Views
Atascado con la parte de autorización de Next Auth. Error: la API de acción con HTTP GET no es compatible con NextAuth.js

Recibo un error extraño durante los últimos días. No se puede autenticar mi aplicación Next.js con credenciales.

Hasta donde yo sé, todo es correcto según el doc.

Tampoco puedo ver una solicitud de red en mis herramientas de desarrollo de Chrome.

 import NextAuth from "next-auth"; import CredentialProvider from "next-auth/providers/credentials"; import { signOut,useSession,signIn } from 'next-auth/react'; import { axios } from 'axios'; import { API_URL } from "../../../helpers/api/mutations"; export default NextAuth({ providers: [ CredentialProvider({ name: "credentials", credentials: { username: { label: "Email", type: "text", placeholder: "mani@test.com" }, password: { label: "Password", type: "password" }}, // My authorize function where I called my graphql mutation for token and session. async authorize(credentials,req) { const {data} = await axios({ url: API_URL, method: 'post', data: { query: `mutation { login( mobileNumber: "4738291046", mobileCountryCode: "00", password: "admin123" ) { expiresAt accessToken } }` } }) .then(res => { console.log(res.data); }) .catch(err => { console.log(err.message); }); if (data) { console.log(data,'dataaa'); return data } else { return null } } }), ], callbacks: { jwt: ({ token, user }) => { // first time jwt callback is run, user object is available if (user) { token.id = user.id; } return token; }, session: ({ session, token }) => { if (token) { session.id = token.id; } return session; }, }, secret: "test", jwt: { secret:"test", encryption: true, }, pages: { signIn: "api/auth/sigin", }, });
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Me encontré con esto porque olvidé el valor inicial / en mi página de inicio de sesión personalizada:

 pages: { signIn: "/api/auth/sigin", }
about 4 years ago · Juan Pablo Isaza Report

0

El problema puede estar relacionado con la forma en que ha manejado async/await en la función de authorize .

Prueba a cambiarlo así:

 async authorize(credentials,req) { try { const { data } = await axios({ url: API_URL, method: 'post', data: { query: `mutation { login( mobileNumber: "4738291046", mobileCountryCode: "00", password: "admin123" ) { expiresAt accessToken } }` } }) if (data) { console.log(data,'dataaa'); return data } else { return null } } catch (err) { return null } }
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!