Captures the AUTH_URL gotcha I hit during the live-stack smoke run.
.env.example now pins AUTH_URL=http://acme.localhost:3000 and includes a long-form comment explaining why.
README's local-dev section adds an 'AUTH_URL gotcha' callout.
Why
Auth.js v5 builds the OAuth redirect_uri from AUTH_URL — not from the request Host header, even with AUTH_TRUST_HOST=true. If you visit http://acme.localhost:3000 while AUTH_URL=http://localhost:3000, Keycloak rejects the token exchange with invalid_grant: Incorrect redirect_uri because the PKCE cookie was set on acme.localhost but the callback URL Auth.js sent points at localhost. Took an hour of poking at Host headers + AUTH_TRUST_HOST + cookie scoping to land on this.
In prod, orca-proxy passes the actual host via X-Forwarded-Host and AUTH_URL is set to the apex (https://breakpilot.com).
Refs: M5.1 follow-up
Risk
Doc + env-template only.
## What
Captures the AUTH_URL gotcha I hit during the live-stack smoke run.
- `.env.example` now pins `AUTH_URL=http://acme.localhost:3000` and includes a long-form comment explaining why.
- README's local-dev section adds an 'AUTH_URL gotcha' callout.
## Why
Auth.js v5 builds the OAuth `redirect_uri` from `AUTH_URL` — **not** from the request Host header, even with `AUTH_TRUST_HOST=true`. If you visit `http://acme.localhost:3000` while `AUTH_URL=http://localhost:3000`, Keycloak rejects the token exchange with `invalid_grant: Incorrect redirect_uri` because the PKCE cookie was set on `acme.localhost` but the callback URL Auth.js sent points at `localhost`. Took an hour of poking at Host headers + AUTH_TRUST_HOST + cookie scoping to land on this.
In prod, orca-proxy passes the actual host via X-Forwarded-Host and `AUTH_URL` is set to the apex (`https://breakpilot.com`).
Refs: M5.1 follow-up
## Risk
Doc + env-template only.
Live-stack debugging caught this: Auth.js v5 builds the OAuth
redirect_uri from AUTH_URL, NOT from the request Host header, even
with AUTH_TRUST_HOST=true. If you visit http://acme.localhost:3000
with AUTH_URL=http://localhost:3000, Keycloak rejects the token
exchange because the PKCE cookie was set on acme.localhost but the
callback URL Auth.js sent was localhost.
Fix in dev: pin AUTH_URL to the subdomain you're testing on. In prod,
orca-proxy passes the right host via X-Forwarded-Host and AUTH_URL
is set to the apex.
Updates .env.example with a long-form note + sets AUTH_URL to the
acme tenant so a copy/paste-and-go workflow Just Works. Adds a
'AUTH_URL gotcha' callout to the local-dev section in README.
Refs: M5.1
CODEOWNERS rules
requested review from Benjamin_Boenisch 2026-05-19 16:04:43 +00:00
sharang
merged commit 8ab82c8b37 into main2026-05-19 16:05:45 +00:00
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
What
Captures the AUTH_URL gotcha I hit during the live-stack smoke run.
.env.examplenow pinsAUTH_URL=http://acme.localhost:3000and includes a long-form comment explaining why.Why
Auth.js v5 builds the OAuth
redirect_urifromAUTH_URL— not from the request Host header, even withAUTH_TRUST_HOST=true. If you visithttp://acme.localhost:3000whileAUTH_URL=http://localhost:3000, Keycloak rejects the token exchange withinvalid_grant: Incorrect redirect_uribecause the PKCE cookie was set onacme.localhostbut the callback URL Auth.js sent points atlocalhost. Took an hour of poking at Host headers + AUTH_TRUST_HOST + cookie scoping to land on this.In prod, orca-proxy passes the actual host via X-Forwarded-Host and
AUTH_URLis set to the apex (https://breakpilot.com).Refs: M5.1 follow-up
Risk
Doc + env-template only.