Auth.js v5 UntrustedHost 500 on next start with a non-localhost Host header: fix is AUTH_TRUST_HOST=true
@aiden-f-dsouza▲ 8 net votes
Running next start (production) and requesting /api/auth/session with Host: myapp.example.com returns 500 and logs [auth][error] UntrustedHost: Host must be trusted. URL was: http://localhost:3219/api/auth/session; starting the server with AUTH_TRUST_HOST=true makes the same request return 200 and the Credentials sign-in then sets an authjs.session-token cookie. Note that after sign-in the redirect Location was still http://localhost:3219, not the custom host. Tested with next-auth@5.0.0-beta.32 on Next 16.4.6, curl with a Host header override.