diff --git a/package.json b/package.json index 54651bfd..b954d381 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ }, "scripts": { "dev": "pnpm --filter @faunosteo/app dev", + "dev:lan": "bash scripts/dev-lan.sh", "preview": "pnpm --filter @faunosteo/app preview", "build": "pnpm -r build", "typecheck": "pnpm -r typecheck", diff --git a/scripts/dev-lan.sh b/scripts/dev-lan.sh new file mode 100755 index 00000000..b1cb99cc --- /dev/null +++ b/scripts/dev-lan.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash +# Vite dev server reachable from the LAN, wired to the local Supabase stack by the +# host's LAN address (the stack publishes 54321 / 54323 / 54324 on every interface). +# Usage: pnpm dev:lan [host-ip] (default: the first non-loopback IPv4 of this host) +set -euo pipefail +cd "$(dirname "$0")/.." +ip="${1:-$(hostname -I 2>/dev/null | awk '{print $1}')}" +[ -n "$ip" ] || { echo "dev-lan: pass the host IP as the first argument" >&2; exit 1; } +anon="$(node_modules/.bin/supabase status -o env 2>/dev/null | sed -n 's/^ANON_KEY="\(.*\)"$/\1/p')" +[ -n "$anon" ] || { echo "dev-lan: local stack not running (pnpm db:start)" >&2; exit 1; } +echo "== app http://$ip:5173 supabase http://$ip:54321 studio http://$ip:54323 mailpit http://$ip:54324" +VITE_SUPABASE_URL="http://$ip:54321" VITE_SUPABASE_ANON_KEY="$anon" \ + exec node_modules/.bin/pnpm --filter @faunosteo/app exec vite --host 0.0.0.0 --port 5173 diff --git a/supabase/config.toml b/supabase/config.toml index cc16863e..41957600 100644 --- a/supabase/config.toml +++ b/supabase/config.toml @@ -69,11 +69,16 @@ enabled = false enabled = true # Vite dev server of apps/app site_url = "http://127.0.0.1:5173" +# LAN access (pnpm dev:lan): confirmation and recovery links must land on the +# address the browser used, so every private-network host on :5173 is allowed. additional_redirect_urls = [ "http://127.0.0.1:5173", "http://localhost:5173", "http://127.0.0.1:5173/**", "http://localhost:5173/**", + "http://192.168.*.*:5173/**", + "http://10.*.*.*:5173/**", + "http://172.16.*.*:5173/**", ] jwt_expiry = 3600 enable_refresh_token_rotation = true