#!/bin/sh
set -e

IP="$(ipconfig getifaddr en0 2>/dev/null || true)"
if [ -z "$IP" ]; then
  IP="$(ipconfig getifaddr en1 2>/dev/null || true)"
fi

if [ -z "$IP" ]; then
  echo "Could not determine LAN IP (tried en0/en1)."
  exit 1
fi

export EXPO_PUBLIC_DEV_API_BASE_URL="http://$IP:3000"
echo "Using EXPO_PUBLIC_DEV_API_BASE_URL=$EXPO_PUBLIC_DEV_API_BASE_URL"
exec npx expo start