客户端获取错误next-auth next.js和vercel与自定义域部署
我有一个电子商务部署到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中的自定义域中不在 你能帮助我吗?
回购似乎我的问题之一是提供者没有阅读
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
[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?
I have reviewed and it seems that one of my problems is that the providers are not read
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论