API resolved without sending a response for /api/auth/callback/credentials, this may result in stalled requests
Asked Answered
A

1

1

When i try to login using Talend API Tester, getting this into terminal:

API resolved without sending a response for /api/auth/callback/credentials, this may result in stalled requests.

Besides, here is the image of Request:

enter image description here

I followed this: Next-Auth.js -> Rest API


Why I'm getting this kind of response & warning?

Below is the [..nextauth.js] file's code. What's wrong with my code?

import NextAuth from 'next-auth'
import Providers from 'next-auth/providers'
import prisma from '../../../lib/prisma'

const options = {
    providers: [
        Providers.Credentials({
            name: 'Credentials',
            credentials: {
                email: { label: "Email", type: "email", placeholder: "[email protected]" },
                password: {  label: "Password", type: "password" }
              },
            async authorize(credentials) {
                const {email, password} = credentials
                const user = await prisma.user.findFirst({ where: { email, password } })
                console.log(user);
            
                // If no error and we have user data, return it
                if (user) {
                return user
                }
                // Return null if user data could not be retrieved
                return null
          }
        })
      ]
}

export default async function handle(req, res) {
    console.log('I see');
    NextAuth(req, res, options) 
}

Note: Actually I don't want to send csrfToken in the body. Only email & password to the endpoint. Please have a look into my this question How to do authentication using NextAuth.js without login page (using postman)

Acclimatize answered 10/7, 2021 at 7:56 Comment(2)
Have you tried adding a return before your NextAuth call: return NextAuth(req, res, options)?Comenius
Ya. Hmm same issue: Sorry, the Chrome API does not allow to get a response body for redirect.Acclimatize
P
0

Try to add "json": true in the body.
Something like this:

{
  "csrfToken": YOUR_TOKEN,
  "username": YOUR_USERNAME,
  "password": YOUR_PASSWORD,
  "json": true
}
Promote answered 21/6, 2023 at 12:11 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.