dragonflight/services
Zac Gaetano ac7730195d fix(web-ui): forward X-Forwarded-Proto from outer proxy so mam-api emits Set-Cookie
This is the real cause of the login loop. mam-api sets its session cookie
with Secure=true (production config). express-session refuses to emit a
Secure Set-Cookie unless req.secure is true. With `app.set('trust proxy')`
on, req.secure derives from X-Forwarded-Proto.

web-ui's nginx was unconditionally sending `X-Forwarded-Proto: $scheme`.
Inside the web-ui container nginx listens on port 80, so $scheme is always
"http" — regardless of whether the outer NPM proxy terminated TLS. mam-api
saw http, decided the connection was insecure, and silently dropped the
Set-Cookie from the login response. Login succeeded server-side (session
row landed in PG, last_login_at updated) but the browser never received a
cookie, so the very next /auth/me check came back 401 and AuthGate bounced
to the login screen. Infinite loop.

The previous Connection: "upgrade" → $connection_upgrade fix wasn't wrong
(the hardcode is a real latent bug worth fixing) — it just wasn't the
proximate cause.

Fix: a second `map` directive forwards the outer X-Forwarded-Proto through
when present, falling back to $scheme only when no proxy header exists (so
direct localhost curls still work). Both /api/ and /capture/ now send the
correct value upstream, mam-api sees https, req.secure is true, Set-Cookie
flows through, login works.

Verified by curling the existing direct-to-mam-api path: with X-Forwarded-
Proto: https on the request, Set-Cookie comes back; without it, no
Set-Cookie. That's the exact difference between web-ui-proxied and
direct-to-mam-api in our previous diagnostic curls.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-27 22:11:27 -04:00
..
capture fix(recorders,library): empty-capture handling + right-click context menu 2026-05-23 03:52:30 +00:00
mam-api fix(auth): force HTTPS on dragonflight.live so login cookies stick 2026-05-27 22:00:35 -04:00
node-agent chore: 1.2 ship-prep sweep — close 38 issues 2026-05-27 02:06:14 +00:00
premiere-plugin feat(panel): add .connected-bar CSS for compact connected state 2026-05-27 19:31:16 -04:00
web-ui fix(web-ui): forward X-Forwarded-Proto from outer proxy so mam-api emits Set-Cookie 2026-05-27 22:11:27 -04:00
worker feat(audio-tab): full audio track inspector with meters, mute/solo, faders 2026-05-27 04:53:52 +00:00