pub(super) async fn ws_origin_guard(req: Request<Body>, next: Next) -> ResponseExpand description
Refuse a WebSocket upgrade whose Origin is neither loopback nor allowed
by --allowed-origin (is_allowed_origin).
CORS does not apply to WebSocket upgrades, so without this any web page
holding the auth key could open /ws (cross-site WebSocket hijacking).
The key is not sent automatically the way a cookie would be, so this is
defense in depth rather than a fix for a reachable attack. Browsers always
send Origin on an upgrade; srv’s native clients (launcher, agentmux-mcp)
send none, so a missing header is allowed.