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

683
Views
Client fetch error in Next JS while authenticating the user

My callback where I've loaded session and token.

 callbacks: {
    jwt: async ({ token, user }) => {
      
        
      console.log(user,'sessionn');
      console.log(token,'tokenn');
       if(user?.accessToken){
         token.accessToken = user.accessToken
       }
       
      console.log(user,'sessionn');
      console.log(token,'tokenn');
       return token
    },
    session: async ({ session, user }) => {
      if(user?.accessToken){
        session = user.expiresAt;

      }
        return session
    }
},

The user object I'm returning.

   {
        "accessToken": "a36458ef4f53f2b9fd1784bbf33bea78",
        "expiresAt": "2022-02-23T18:30:00Z"
    }

Result I get after running the app. The session is declared any how in callbacks

[next-auth][error][CLIENT_FETCH_ERROR] 
https://next-auth.js.org/errors#client_fetch_error invalid json response body at http://localhost:3000/;/session reason: Unexpected token < in JSON at position 0 {
  error: {
    message: 'invalid json response body at http://localhost:3000/;/session reason: Unexpected token < in JSON at position 0',
    stack: 'FetchError: invalid json response body at http://localhost:3000/;/session reason: Unexpected token < in JSON at position 0\n' +
      '    at G:\\mentorapp\\captain-webapp-FE\\node_modules\\node-fetch\\lib\\index.js:272:32\n' +
      '    at processTicksAndRejections (node:internal/process/task_queues:96:5)',
    name: 'FetchError'
  },
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!