Skip to content

A modern and easy to use dashboard. 80+ integrations. 20K+ icons built in. Authentication out of the box. No YAML, drag and drop configuration.

fix: next auth host not trusted (#144)

Meier Lukasb2cee8f6936d
diff --git a/apps/nextjs/src/app/[locale]/auth/login/_login-form.tsx b/apps/nextjs/src/app/[locale]/auth/login/_login-form.tsx
index d0a3f03de..7191ba68b 100644
--- a/apps/nextjs/src/app/[locale]/auth/login/_login-form.tsx
+++ b/apps/nextjs/src/app/[locale]/auth/login/_login-form.tsx
@@ -40,7 +40,7 @@ export const LoginForm = () => {
callbackUrl: "/",
})
.then((response) => {
- if (!response?.ok) {
+ if (!response?.ok || response.error) {
throw response?.error;
}
diff --git a/packages/auth/configuration.ts b/packages/auth/configuration.ts
index 32289da46..f1d47a2a6 100644
--- a/packages/auth/configuration.ts
+++ b/packages/auth/configuration.ts
@@ -14,6 +14,19 @@ const adapter = DrizzleAdapter(db);
export const createConfiguration = (isCredentialsRequest: boolean) =>
NextAuth({
+ logger: {
+ error: (code, ...message) => {
+ // Remove the big error message for failed login attempts
+ // as it is not useful for the user.
+ if (code.name === "CredentialsSignin") {
+ console.warn("The login attempt of a user was not successful.");
+ return;
+ }
+
+ console.error(code, ...message);
+ },
+ },
+ trustHost: true,
adapter,
providers: [
Credentials(createCredentialsConfiguration(db)),
diff --git a/packages/auth/providers/credentials.ts b/packages/auth/providers/credentials.ts
index 04470dbfa..42bec2497 100644
--- a/packages/auth/providers/credentials.ts
+++ b/packages/auth/providers/credentials.ts
@@ -30,6 +30,7 @@ export const createCredentialsConfiguration = (db: Database) =>
});
if (!user?.password) {
+ console.log(`user ${data.name} was not found`);
return null;
}