dheraingoud's picture
feat: synchronize proxy with upstream commits up to 5305bd7 and integrate NIM key rotator
0a54372
Raw
History Blame Contribute Delete
895 Bytes
"""Browser-friendly local server URLs shared by runtime and launchers."""
from free_claude_code.config.settings import Settings
def _browser_host_for_local_urls(settings: Settings) -> str:
"""Host fragment for URLs shown to humans on the same machine as the server."""
host = settings.host.strip() if settings.host else "127.0.0.1"
if host in {"0.0.0.0", "::", "[::]"}:
host = "127.0.0.1"
if ":" in host and not host.startswith("["):
host = f"[{host}]"
return host
def local_proxy_root_url(settings: Settings) -> str:
"""Return the proxy root URL (no path) for clients on the same machine."""
return f"http://{_browser_host_for_local_urls(settings)}:{settings.port}"
def local_admin_url(settings: Settings) -> str:
"""Return a browser-friendly URL for the localhost-only admin UI."""
return f"{local_proxy_root_url(settings)}/admin"