diff --git a/bin/local-dev/main.sh b/bin/local-dev/main.sh index 58fa687f0d6..ecca64b25d8 100755 --- a/bin/local-dev/main.sh +++ b/bin/local-dev/main.sh @@ -466,6 +466,15 @@ fi # Both platform probes follow the same two steps: the interface backing the # default route first (most reliable on a laptop that may have wifi + # thunderbolt + tailscale all active), then a scan as a fallback. +_detect_host_lan_ip_windows() { + local ip="" + ip=$(ipconfig 2>/dev/null | grep -i "IPv4" | head -n 1 | awk -F: '{print $2}' | tr -d '[:space:]' | tr -d '\r') + if [[ -n "$ip" && "$ip" != 127.* ]]; then + printf '%s\n' "$ip"; return 0; + fi + return 1 +} + _detect_host_lan_ip_darwin() { local iface="" ip="" iface=$(route get default 2>/dev/null | awk '/interface:/{print $2; exit}') @@ -520,8 +529,9 @@ _detect_host_lan_ip() { case "$(uname -s 2>/dev/null)" in Darwin) _detect_host_lan_ip_darwin ;; Linux) _detect_host_lan_ip_linux ;; + MINGW*|MSYS*|CYGWIN*|*_NT*) _detect_host_lan_ip_windows ;; # Anything else (BSD, WSL oddities): try both rather than give up. - *) _detect_host_lan_ip_darwin || _detect_host_lan_ip_linux ;; + *) _detect_host_lan_ip_darwin || _detect_host_lan_ip_linux || _detect_host_lan_ip_windows ;; esac } # Lazy resolver — called from subcommands that actually need to publish a