fix(HEL-564): 数据中枢入口固定内网 IP,不再按主机名推导

- 主站桌面端/移动端「数据中枢」入口固定 http://192.168.200.11:8766/admin/
  (XIAOBAI_DATAHUB_URL 仍可覆盖):域名只反代 8765,推导出的 <域名>:8766 打不开,
  同时避免数据中枢被外网摸到
- 中枢 _review_url 不再从 Host 头推导,统一取 REVIEW_PUBLIC_URL,
  默认 http://192.168.200.11:8765;compose 与 .env.example 示例值同步
- 补回归测试:Host 为域名且未配 REVIEW_PUBLIC_URL 时登录链接仍为固定内网地址
- 文档写明 Cookie 按门牌区分的边界与部署说明

Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
施工员
2026-09-16 15:23:45 +08:00
co-authored by multica-agent
parent b402b3b2a8
commit a4dbe2bcf8
12 changed files with 50 additions and 27 deletions
+6 -8
View File
@@ -11,6 +11,7 @@ from urllib.parse import unquote, urlparse
from datahub.hub import Hub
from datahub.logutil import configure_logging, get_logger
from datahub.serving import ApiError, parse_query
from datahub.settings import DEFAULT_REVIEW_PUBLIC_URL
from datahub.siteauth import SITE_SESSION_COOKIE, SiteBridgeError
LOGGER = get_logger()
@@ -212,15 +213,12 @@ class HubRequestHandler(BaseHTTPRequestHandler):
def _review_url(self) -> str:
"""Browser-reachable review site URL.
In production both services sit on the same host behind different
ports, so the console derives the site URL from the Host header the
browser used; REVIEW_PUBLIC_URL overrides that when they do not.
HEL-564: fixed to REVIEW_PUBLIC_URL (default the intranet address)
instead of being derived from the browser's Host header — a domain
that only proxies 8765 would send the console back to a dead port.
"""
configured = self.hub.settings.review_public_url
if configured:
return configured.rstrip("/")
host = (self.headers.get("Host") or "").split(":")[0] or "127.0.0.1"
return f"http://{host}:8765"
configured = self.hub.settings.review_public_url or DEFAULT_REVIEW_PUBLIC_URL
return configured.rstrip("/")
def _login_url(self) -> str:
return f"{self._review_url()}/login/"