客户端获取错误next-auth next.js和vercel与自定义域部署

发布于 2025-02-10 01:48:38 字数 2613 浏览 5 评论 0原文

我有一个电子商务部署到vercel中,我将Next-auth用于身份验证,当我尝试登录时,它会抱怨并启动错误

“

[NextAuth] .ts

export default NextAuth({
  providers: [
    Credentials({
      name: "Custom Login",
      credentials: {
        email: {
          label: "Correo:",
          type: "email",
          placeholder: "[email protected]",
        },
        password: {
          label: "Contraseña:",
          type: "password",
          placeholder: "Contraseña",
        },
      },
      async authorize(credentials) {
        console.log({ credentials });

        return await dbUsers.checkUserEmailPassword(
          credentials!.email,
          credentials!.password
        );
      },
    }),

login.tsx

const onLoginUser = async ({ email, password }: FormData) => {
    setShowError(false);

    await signIn("credentials", { email, password });

    
  };

这是我的回答:

[![2022-06-23T08:45:36.199Z 33d4ff25-ada2-4054-9050-68eec5626886    ERROR   \[next-auth\]\[error\]\[CLIENT_FETCH_ERROR\] 
https://next-auth.js.org/errors#client_fetch_error invalid json response body at https://madrugon-8dxawm6jh-madrugon-admin.vercel.app/api/auth/session reason: Unexpected token < in JSON at position 0 {
  error: {
    message: 'invalid json response body at https://madrugon-8dxawm6jh-madrugon-admin.vercel.app/api/auth/session reason: Unexpected token < in JSON at position 0',
    stack: 'FetchError: invalid json response body at https://madrugon-8dxawm6jh-madrugon-admin.vercel.app/api/auth/session reason: Unexpected token < in JSON at position 0\n' +
      '    at /var/task/node_modules/next/dist/compiled/node-fetch/index.js:1:49606\n' +
      '    at processTicksAndRejections (node:internal/process/task_queues:96:5)',
    name: 'FetchError'
  },
  path: 'session',][1]][1]

在Heroku和本地工作完美,但在Vercel中的自定义域中不在 你能帮助我吗?

自定义域的链接

heroku上的链接

我的

回购似乎我的问题之一是提供者没有阅读

I have an e-commerce that I deploy into vercel, I used next-auth for authentication, when i try to login it's complains and launch an error

enter image description here

[nextauth].ts

export default NextAuth({
  providers: [
    Credentials({
      name: "Custom Login",
      credentials: {
        email: {
          label: "Correo:",
          type: "email",
          placeholder: "[email protected]",
        },
        password: {
          label: "Contraseña:",
          type: "password",
          placeholder: "Contraseña",
        },
      },
      async authorize(credentials) {
        console.log({ credentials });

        return await dbUsers.checkUserEmailPassword(
          credentials!.email,
          credentials!.password
        );
      },
    }),

login.tsx

const onLoginUser = async ({ email, password }: FormData) => {
    setShowError(false);

    await signIn("credentials", { email, password });

    
  };

this is my response:

[![2022-06-23T08:45:36.199Z 33d4ff25-ada2-4054-9050-68eec5626886    ERROR   \[next-auth\]\[error\]\[CLIENT_FETCH_ERROR\] 
https://next-auth.js.org/errors#client_fetch_error invalid json response body at https://madrugon-8dxawm6jh-madrugon-admin.vercel.app/api/auth/session reason: Unexpected token < in JSON at position 0 {
  error: {
    message: 'invalid json response body at https://madrugon-8dxawm6jh-madrugon-admin.vercel.app/api/auth/session reason: Unexpected token < in JSON at position 0',
    stack: 'FetchError: invalid json response body at https://madrugon-8dxawm6jh-madrugon-admin.vercel.app/api/auth/session reason: Unexpected token < in JSON at position 0\n' +
      '    at /var/task/node_modules/next/dist/compiled/node-fetch/index.js:1:49606\n' +
      '    at processTicksAndRejections (node:internal/process/task_queues:96:5)',
    name: 'FetchError'
  },
  path: 'session',][1]][1]

in heroku and locally works perfect but not in custom domain in vercel
¿can you help me?

Link of custom domain

Link on heroku

My repo

I have reviewed and it seems that one of my problems is that the providers are not read

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文