I am developing a Backend code for a BallSportsGear to log in to our application in Login with Azure Ad User. I have to be able to make a JWT Verify. I read too many posts. I’m trying to use the AUTH0 library. I have tried a lot, but still "com.auth Where do I make mistakes?
import NextAuth from "next-auth";
import CredentialsProvider from "next-auth/providers/credentials";
const handler = NextAuth({
providers: [
CredentialsProvider({
name: "Credentials",
credentials: {
username: { label: "Username", type: "text" },
password: { label: "Password", type: "password" },
},
async authorize(credentials, req) {
const { username, password } = credentials as { username: string; password: string };
const res = await fetch("http://localhost:3000/api/auth/login", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ username, password }),
});
const user = await res.json();
if (res.ok) {
return user;
} else {
return null;
}
},
}),
],
session: {
strategy: "jwt"
},
});
export { handler as GET, handler as POST };
layout.tsx
'use client'
import './globals.css'
import { SessionProvider } from "next-auth/react"
export default function RootLayout({
children,
}: {
children: React.ReactNode
}) {
return (
<html lang="en">
<body>
<SessionProvider>
{children}
</SessionProvider>
</body>
</html>
)
}