forked from Alishahryar1/free-claude-code
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver_urls.py
More file actions
26 lines (16 loc) · 895 Bytes
/
Copy pathserver_urls.py
File metadata and controls
26 lines (16 loc) · 895 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
"""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"