Tweak: improve nextauth error logging for easier debugging (#7070)
Docker CI / Docker Build & Push (push) Has been cancelled
Lint / Linting Checks (push) Has been cancelled
Release Drafter / Update Release Draft (push) Has been cancelled
Release Drafter / Auto Label PR (push) Has been cancelled
Tests / vitest (1) (push) Has been cancelled
Tests / vitest (2) (push) Has been cancelled
Tests / vitest (3) (push) Has been cancelled
Tests / vitest (4) (push) Has been cancelled

This commit is contained in:
shamoon
2026-08-28 12:23:55 -07:00
committed by GitHub
parent c46b3e6cff
commit e6ad43a76c
2 changed files with 13 additions and 2 deletions
+11 -1
View File
@@ -71,6 +71,16 @@ function logFailedPasswordSignIn() {
createLogger("nextauth").warn("Failed password sign-in attempt");
}
function logNextAuthError(code, metadata) {
const error = metadata instanceof Error ? metadata : metadata?.error;
if (error?.message) {
createLogger("nextauth").error("%s: %s", code, error.message);
} else {
createLogger("nextauth").error("%s", code);
}
}
let providers = [];
if (authEnabled) {
if (hasOidcConfig) {
@@ -140,7 +150,7 @@ export const authOptions = {
signIn: "/auth/signin",
},
logger: {
error: (code) => createLogger("nextauth").error("%s", code),
error: logNextAuthError,
warn: (code) => createLogger("nextauth").warn("%s", code),
debug: (code) => createLogger("nextauth").debug("%s", code),
},