Fix Auth.js server error behind reverse proxy

Add trustHost: true to NextAuth config so Auth.js accepts requests
when running behind Traefik/reverse proxy. Without this, Auth.js
rejects the credential callback because the forwarded host doesn't
match its expectations.

Made-with: Cursor
This commit is contained in:
Randall Stillwell 2026-04-15 01:50:44 -05:00
parent 95a672a6cb
commit 04e9811572
2 changed files with 3 additions and 0 deletions

View file

@ -19,6 +19,8 @@ WATCH_DIR=""
# Auth.js (required — generate with: npx auth secret) # Auth.js (required — generate with: npx auth secret)
AUTH_SECRET="" AUTH_SECRET=""
# Set AUTH_URL to your external URL when behind a reverse proxy
AUTH_URL="https://staging.echoocr.stillwell.cloud"
# Authentik OIDC SSO (optional — enables "Sign in with SSO" button) # Authentik OIDC SSO (optional — enables "Sign in with SSO" button)
# Create an OAuth2/OIDC provider in Authentik and set these values. # Create an OAuth2/OIDC provider in Authentik and set these values.

View file

@ -7,6 +7,7 @@ import { prisma } from "@/lib/db";
export const { handlers, auth, signIn, signOut } = NextAuth({ export const { handlers, auth, signIn, signOut } = NextAuth({
adapter: PrismaAdapter(prisma), adapter: PrismaAdapter(prisma),
session: { strategy: "jwt" }, session: { strategy: "jwt" },
trustHost: true,
pages: { pages: {
signIn: "/login", signIn: "/login",
}, },