You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(server): self-explaining 403 for rejected forwarded hosts (#568)
## Summary
Follow-up to the 403 path discussed in #562. When agentsview is reached through SSH port-forwarding, a reverse proxy, or a remote dev environment (exe.dev, Codespaces, Coder, WSL2), the browser sends a `Host` the server does not trust, so `/api/v1/settings` is rejected with a bare `403 Forbidden` — with no server log and no body explaining why. The only escape was already knowing to pass `--public-url`.
This makes the existing behavior self-explaining without loosening it:
- **Server:** on a host-check rejection, `hostCheckMiddleware` writes a breadcrumb to the debug log (rejected `Host`, the allowed set, and a `--public-url` hint) and returns a descriptive `403` body instead of bare "Forbidden". Fails closed exactly as before — the DNS-rebinding guard is unchanged.
- **Frontend:** the settings store surfaces an actionable origin-rejection message on `403` (preferring the server's descriptive body), rather than the generic error. Complements #563, which stopped `403` from showing the misleading auth-token prompt.
- **Docs:** a "Remote / forwarded access" section in the README covering the forwarded-host case and the `--public-url` / `--public-origin` flags.
Verified end-to-end against the compiled binary on a single machine, including a real `socat` port-forward (equivalent to `ssh -L`) that reproduces the bare 403, and confirmation that `--public-url <forwarded-origin>` resolves it while an untrusted Host still gets 403. The breadcrumb lands in `<dataDir>/debug.log` — the same file referenced in #562.
Refs #562
Co-authored-by: Matthew Jacobs <mjacobs@users.noreply.github.com>
0 commit comments