所以我在Next.js中使用next-auth学习身份验证。我遵循了文档,下面是我的app/api/auth/[...nextauth]/route.ts
代码
import NextAuth, { type NextAuthOptions } from "next-auth";
import GithubProvider from "next-auth/providers/github";
import CredentialsProvider from "next-auth/providers/credentials";
export const authOptions: NextAuthOptions = {
providers: [
GithubProvider({
clientId: process.env.GITHUB_ID as string,
clientSecret: process.env.GITHUB_SECRET as string,
}),
CredentialsProvider({
name: "Credentials",
credentials: {
username: {
label: "Username",
type: "text",
placeholder: "John Smith",
},
password: {
label: "Password",
type: "password",
placeholder: "*******",
},
},
async authorize(credentials) {
// here data should come from the database
const user = { id: "1", name: "John", password: "pass" };
if (
credentials?.username === user.name &&
credentials.password === user.password
) {
return user;
} else {
return null;
}
},
}),
],
};
const handler = NextAuth(authOptions);
export { handler as GET, handler as POST };
字符串
我在这个文件中得到一个错误
This expression is not callable.
Type 'typeof import("e:/Javascript/learnauth2/node_modules/next-auth/next")' has no call signatures.ts(2349)
型
我拥有的next-auth
版本是4.22.2
,next
版本是13.4.10
任何有关这方面的帮助是赞赏
1条答案
按热度按时间p4rjhz4m1#
我想我找到了解决这个问题的办法。我试了
npm update
和boom!没有错误。不知道主要问题是什么