INNER CODE UNIT · Python
_require_local_origin
AaronL725/grok-register · web/server.py:170
def _require_local_origin(request: Request) -> None:
origin = str(request.headers.get("origin") or "").strip()
if not origin:
return
from urllib.parse import urlsplit
host = (urlsplit(origin).hostname or "").lower()
if host not in {"127.0.0.1", "localhost", "::1"}:
raise HTTPException(status_code=403, detail="Outlook 邮箱池只允许本地 WebUI 访问")
@app.get("/health")
def health():
return {"ok": True}
@app.get("/api/config")
def get_config():
return {"ok": True, "config": _load_config_if_idle()}