#!/usr/bin/env bash # Start dev stack with the API reachable from an iPhone on the same LAN. set -euo pipefail ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" cd "$ROOT" if [[ ! -f .env ]]; then echo "Missing .env — run: cp .env.example .env and fill secrets." >&2 exit 1 fi set_env_var() { local key="$1" local value="$2" if grep -q "^${key}=" .env; then perl -pi -e "s/^\\Q${key}=\\E.*/${key}=${value}/" .env else printf '\n%s=%s\n' "$key" "$value" >> .env fi } lan_ipv4() { local os ip iface os="$(uname -s)" if [[ "$os" == Darwin ]]; then for iface in en0 en1 bridge100; do ip="$(ipconfig getifaddr "$iface" 2>/dev/null || true)" if [[ -n "$ip" ]]; then echo "$ip" return 0 fi done return 1 fi if command -v ip >/dev/null 2>&1; then ip route get 1.1.1.1 2>/dev/null | awk '{for (i=1;i<=NF;i++) if ($i=="src") { print $(i+1); exit }}' return 0 fi hostname -I 2>/dev/null | awk '{print $1}' } set_env_var API_HOST "0.0.0.0" IP="$(lan_ipv4 || true)" PORT="${API_PORT:-3100}" echo "" echo "evOo LAN (iPhone / iPad)" echo " 1. Same Wi‑Fi as this machine; allow incoming TCP ${PORT} in the firewall." echo " 2. In the evOo app: Sign in → Custom server" if [[ -n "$IP" ]]; then echo " 3. Server URL: http://${IP}:${PORT}" else echo " 3. Server URL: http://:${PORT}" echo " (Could not detect LAN IP — check System Settings → Network.)" fi echo "" echo "Starting pnpm dev …" exec pnpm dev