You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Vercel预览部署遇Next-Auth CLIENT_FETCH_ERROR求助

Vercel预览部署中Next-Auth CLIENT_FETCH_ERROR问题求助

错误详情

[next-auth][error][CLIENT_FETCH_ERROR] 
https://next-auth.js.org/errors#client_fetch_error Unexpected token < in JSON at position 0 {
  error: {
    message: 'Unexpected token < in JSON at position 0',
    stack: 'SyntaxError: Unexpected token < in JSON at position 0\n' +
      '    at JSON.parse (<anonymous>)\n' +
      '    at parseJSONFromBytes (node:internal/deps/undici/undici:6498:19)\n' +
      '    at successSteps (node:internal/deps/undici/undici:6472:27)\n' +
      '    at node:internal/deps/undici/undici:1145:60\n' +
      '    at node:internal/process/task_queues:140:7\n' +
      '    at AsyncResource.runInAsyncScope (node:async_hooks:204:9)\n' +
      '    at AsyncResource.runMicrotask (node:internal/process/task_queues:137:8)\n' +
      '    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)',
    name: 'SyntaxError'
  },
  url: 'https://[my-censored-domain-name].com/api/auth/providers',
  message: 'Unexpected token < in JSON at position 0'
}

预期返回的JSON数据

{
   "google":{
      "id":"google",
      "name":"Google",
      "type":"oauth",
      "signinUrl":"https://[my-censored-domain-name].com/api/auth/signin/google",
      "callbackUrl":"https://[my-censored-domain-name].com/api/auth/callback/google"
   },
   "email":{
      "id":"email",
      "name":"Email",
      "type":"email",
      "signinUrl":"https://[my-censored-domain-name].com/api/auth/signin/email",
      "callbackUrl":"https://[my-censored-domain-name].com/api/auth/callback/email"
   }
}

已尝试但未解决问题的方案

  • 将NEXTAUTH_URL设置为自定义域名(非Vercel域名)
  • 配置NEXTAUTH_SECRET环境变量
  • 在[...next-auth].ts中添加secret字段并关联NEXTAUTH_SECRET
  • 临时添加环境变量NEXTAUTH_INTERNAL_URL = http://localhost:8080
  • 在signIn()调用前添加e.preventDefault()

Next-Auth文档提示需设置NEXTAUTH_URL,但我已在Vercel中正确配置该变量,恳请各位提供解决思路。


内容的提问来源于stack exchange,提问作者nonamorando

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.22 04:22:40