我想尝试nextjs和next,以便与凭证提供程序进行身份验证。但是,当我登录并尝试打开受保护的路由时,总是会收到以下错误:
[next-auth][error][client_fetch_error]
https://next-auth.js.org/errors#client_fetch_error session FetchError: invalid json response body at http://localhost:3000/api/auth/session reason: Unexpected token < in JSON at position 0
at C:\Users\me\workspace\vscode\projects\next-auth-typescript-example\node_modules\node-fetch\lib\index.js:272:32
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:95:5) {
type: 'invalid-json'
}要再现错误,可以执行以下步骤:
/pages/api/auth/[...nextauth].ts凭据提供程序的代码:
Providers.Credentials({
name: "Ogame Credentials",
credentials: {
username: { label: "Username", type: "text" },
password: { label: "Password", type: "password" },
},
async authorize(credentials, req) {
const user: User = {
id: 1,
name: "J Smith",
email: "jsmith@example.com",
image: "https://google.de",
}
if (user) {
return user
} else {
return null
}
},
}),这个代码也来自下一个-auth的例子。
发布于 2021-10-06 16:32:43
好吧,我发现问题了。我为我的python环境安装了miniconda。我没有意识到在默认情况下,迷你钩会进入powershell (base在powershell行前面)
所以我为powershell取消了miniconda的功能,现在它开始工作了。
https://stackoverflow.com/questions/69465887
复制相似问题