fix(webui): allow LAN access when host is 0.0.0.0

The webui bootstrap endpoint (/webui/bootstrap) rejected all non-localhost
connections with HTTP 403, preventing the embedded webui from working when
accessed from another device on the LAN — even when host was set to 0.0.0.0.

Skip the localhost check when the server is explicitly bound to 0.0.0.0 or ::,
since that signals intent to accept external connections.
This commit is contained in:
chengyongru
2026-05-06 23:00:23 +08:00
committed by Xubin Ren
parent 790a03ec28
commit bad584cb0e
3 changed files with 61 additions and 1 deletions
+3 -1
View File
@@ -607,7 +607,9 @@ class WebSocketChannel(BaseChannel):
self._api_tokens.pop(token_key, None)
def _handle_webui_bootstrap(self, connection: Any) -> Response:
if not _is_localhost(connection):
if self.config.host not in ("0.0.0.0", "::") and not _is_localhost(
connection,
):
return _http_error(403, "webui bootstrap is localhost-only")
# Cap outstanding tokens to avoid runaway growth from a misbehaving client.
self._purge_expired_issued_tokens()