auth: request tracing + configurable Better Auth log level (debug OAuth flow)
build / test (push) Successful in 14s
build / build (push) Successful in 13s

This commit is contained in:
2026-07-05 22:48:20 -04:00
parent 4e49632e23
commit b6c0751687
2 changed files with 7 additions and 0 deletions
+1
View File
@@ -50,6 +50,7 @@ export const auth = betterAuth({
// its default basePath while generated URLs/issuer keep the /auth prefix.
baseURL: required("BETTER_AUTH_URL"),
secret: required("BETTER_AUTH_SECRET"),
logger: { level: (process.env.LOG_LEVEL as "debug" | "info") ?? "info" },
trustedOrigins: (process.env.TRUSTED_ORIGINS ?? "").split(",").filter(Boolean),
database: pool,
socialProviders,
+6
View File
@@ -54,6 +54,12 @@ ${auth.options.socialProviders && "apple" in auth.options.socialProviders ? soci
const server = createServer((req, res) => {
const url = new URL(req.url ?? "/", "http://localhost");
if (url.pathname !== "/healthz") {
// Request-level trace (path only, no query — avoids logging codes/tokens).
// eslint-disable-next-line no-console
console.log(`[req] ${req.method} ${url.pathname}`);
res.on("finish", () => console.log(`[res] ${req.method} ${url.pathname} -> ${res.statusCode}`));
}
if (url.pathname === "/healthz") {
res.writeHead(200, { "content-type": "application/json" });
res.end('{"status":"ok"}');