Currently i'm trying to create user authentication with NextAuth. I'm able to use it inside my webapp and there is no problem with it. But now, i'm trying to hit the sign in with postman. So i can share the login end point. Here is my [...nextauth].js
const configuration = {
secret: process.env.NEXTAUTH_SECRET,
cookie: {
secure: process.env.NODE_ENV && process.env.NODE_ENV === 'production',
},
session: {
strategy: "jwt",
maxAge: 30 * 24 * 60 * 60
},
providers: [
CredentialsProvider({
id: "credentials",
name: "credentials",
credentials: {},
page: "/",
async authorize(credentials) {
try
{
const user = await prisma.user.findFirst({
where: {
email: credentials.email
}
});
if (user !== null)
{
const res = await confirmPasswordHash(credentials.password, user.password);
if (res === true)
{
return user;
}
else
{
console.log("Hash not matched logging in");
return null;
}
}
else {
return null;
}
}
catch (err)
{
console.log("Authorize error:", err);
}
}
}),
],
callbacks: {
async session({ session, user, token }) {
session.user = token.user;
return session;
},
async jwt({ token, user, account, profile, isNewUser }) {
if (user) {
token.user = user;
}
return token;
},
}
}
export default (req, res) => NextAuth(req, res, configuration)
When i hit via postman, it is returning HTML view.
{
"email":"myemail@email.com",
"password":"12345678"
}
and the data will hit to http://localhost:3000/api/auth/signin
How can i achieve it ? thanks in advance