Providers Credential getting error in Vercel when signin in #1732
-
Your question What are you trying to do Reproduction import NextAuth from "next-auth";
import Providers from "next-auth/providers";
import axios from "axios";
const options = {
site: process.env.NEXTAUTH_URL,
providers: [
Providers.Credentials({
name: "ApprovALL",
credentials: {
username: { label: "Email address", type: "text" },
password: { label: "Password", type: "password" },
},
authorize: async (credentials) => {
try {
const config = {
headers: {
"Content-Type": "application/json; charset=utf-8",
corsOrigin: "*",
"Access-Control-Allow-Origin": "*",
},
};
const user = await axios.post(
`${process.env.NEXTAUTH_URL}/api/auth/callback/signin`,
credentials,
config
);
if (user) {
const userData = user?.data;
return userData;
} else {
return null;
}
} catch (err) {
throw new Error(err?.response?.data?.message);
}
},
}),
],
callbacks: {
async jwt(token, user, account, profile, isNewUser) {
// Add access_token to the token right after signin
if (account?.accessToken) {
token.accessToken = account.accessToken;
}
return token;
},
async session(session, token) {
// Add property to session, like an access_token from a provider.
session.accessToken = token.accessToken;
return session;
},
async redirect(url, baseUrl) {
return url.startsWith(baseUrl) ? url : baseUrl;
},
async signIn(user) {
if (!user.id) {
Promise.reject();
}
return Promise.resolve(true);
},
},
database: process.env.MONGODB_URI,
secret: process.env.JWT_SECRET,
session: {
jwt: true,
// Seconds - How long until an idle session expires and is no longer valid.
maxAge: 7 * 24 * 60 * 60, // 7 days
},
jwt: {
encryption: true,
secret: process.env.JWT_SECRET,
signingKey: process.env.JWT_SIGNING_KEY,
encryptionKey: process.env.JWT_ENCRYPTION_KEY,
},
pages: {
signIn: "/auth/signin",
error: "/auth/signin",
},
theme: "light",
};
export default (req, res) => NextAuth(req, res, options); Additional: attached below the screenshot of the error from Network everytime i visit the site Feedback
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
is there something wrong with my question or any reason why its been closed? @balazsorban44 |
Beta Was this translation helpful? Give feedback.
-
Try to look at Vercel function logs too see the error. Did you set your NEXT-AUTH env variable? |
Beta Was this translation helpful? Give feedback.
-
It looks like the error is coming from /api/auth/callback/signin, which looks to be your own implementation to authorize a user. check your code there. Looks like bcrypt is not installed. |
Beta Was this translation helpful? Give feedback.
It looks like the error is coming from
/api/auth/callback/signin, which looks to be your own implementation to authorize a user. check your code there.
Looks like bcrypt is not installed.