chore(workspace): DEV origin on the private network — scripts/dev-env.sh (FAUNOSTEO_DEV_HOST detected or set), Supabase CLI wrapper, pnpm dev on the LAN address, config.toml URLs via env(); ENVIRONMENTS.md (identity Faunosteo / faunosteo.com, DEV / STAGING / PROD, exposure table, owner procedure)

The owner tests from other devices of the private network: every test
surface is addressed by the machine's LAN address, never 127.0.0.1 or
localhost, never hard-coded. scripts/dev-env.sh decides the host once
(hostname -I, FAUNOSTEO_DEV_HOST override, production hosts refused);
scripts/supabase.sh exports it for every CLI call (pnpm db:*, pnpm supabase)
because config.toml now reads api.external_url (mail links), auth.site_url
and studio.api_url with env(); scripts/dev.sh = pnpm dev on that origin,
pnpm dev:offline keeps the local tool alone; dev-lan.sh removed.
Verified: GoTrue API_EXTERNAL_URL and Studio SUPABASE_PUBLIC_URL on the LAN
address, a signup mail linking to http://<lan>:54321/auth/v1/verify, the
four published ports answering from a separate Docker network, and the
10-step procedure in headless Chromium at the LAN origin with every request
URL audited (no 127.0.0.1 / localhost).
This commit is contained in:
bchanot committed 2026-10-13 22:06:25 +02:00
1 parent f5865f073f
commit dd4c35c061
14 files changed
+228 -41

No files matched your search

+1
View File
@@ -14,6 +14,7 @@ kong="${SUPABASE_INTERNAL_URL:-http://supabase_kong_faunosteo:8000}"
image="${WORKER_IMAGE:-faunosteo_worker:dev}"
name="faunosteo_worker_e2e"
. scripts/dev-env.sh
status="$(node_modules/.bin/supabase status -o env 2>/dev/null)" \
|| { echo "avatar-e2e: the local stack is not running (pnpm db:start)" >&2; exit 1; }
value() { printf '%s\n' "$status" | sed -n "s/^$1=\"\(.*\)\"$/\1/p"; }
+26
View File
@@ -0,0 +1,26 @@
#!/usr/bin/env bash
# shellcheck shell=bash
# The one place the DEV origin is decided (docs/development/ENVIRONMENTS.md §2).
# Sourced by the wrappers (scripts/supabase.sh, scripts/dev.sh, scripts/avatar-e2e.sh):
# every service the browser of another device must reach is addressed by the
# host's LAN address, never by 127.0.0.1 or localhost.
#
# FAUNOSTEO_DEV_HOST the address or name of this machine on the private network;
# unset = the first non-loopback IPv4 of the host; 127.0.0.1 for
# a host-only session. Never a production host.
#
# Exports FAUNOSTEO_DEV_HOST and the derived URLs read by supabase/config.toml
# (env() substitution) and by the Vite dev server.
if [ -z "${FAUNOSTEO_DEV_HOST:-}" ]; then
FAUNOSTEO_DEV_HOST="$(hostname -I 2>/dev/null | awk '{print $1}')"
[ -n "$FAUNOSTEO_DEV_HOST" ] || FAUNOSTEO_DEV_HOST=127.0.0.1
fi
case "$FAUNOSTEO_DEV_HOST" in
*faunosteo.com*) echo "dev-env: FAUNOSTEO_DEV_HOST must never be a production host ($FAUNOSTEO_DEV_HOST)" >&2; return 1 ;;
esac
export FAUNOSTEO_DEV_HOST
export FAUNOSTEO_DEV_API_ORIGIN="http://$FAUNOSTEO_DEV_HOST"
export FAUNOSTEO_DEV_API_URL="http://$FAUNOSTEO_DEV_HOST:54321"
export FAUNOSTEO_DEV_SITE_URL="http://$FAUNOSTEO_DEV_HOST:5173"
export FAUNOSTEO_DEV_STUDIO_URL="http://$FAUNOSTEO_DEV_HOST:54323"
export FAUNOSTEO_DEV_MAILPIT_URL="http://$FAUNOSTEO_DEV_HOST:54324"
-13
View File
@@ -1,13 +0,0 @@
#!/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
Executable
+14
View File
@@ -0,0 +1,14 @@
#!/usr/bin/env bash
# Vite dev server reachable from the private network, wired to the local
# Supabase stack by the DEV origin (scripts/dev-env.sh). Vite listens on every
# interface (apps/app/vite.config.ts server.host); HMR follows the page host.
# pnpm dev # http://<FAUNOSTEO_DEV_HOST>:5173
# pnpm dev:offline # no backend: the local tool alone
set -euo pipefail
cd "$(dirname "$0")/.."
. scripts/dev-env.sh
anon="$(node_modules/.bin/supabase status -o env 2>/dev/null | sed -n 's/^ANON_KEY="\(.*\)"$/\1/p')"
[ -n "$anon" ] || { echo "dev: the local stack is not running (pnpm db:start), or use pnpm dev:offline" >&2; exit 1; }
echo "== app $FAUNOSTEO_DEV_SITE_URL api $FAUNOSTEO_DEV_API_URL studio $FAUNOSTEO_DEV_STUDIO_URL mailpit $FAUNOSTEO_DEV_MAILPIT_URL"
VITE_SUPABASE_URL="$FAUNOSTEO_DEV_API_URL" VITE_SUPABASE_ANON_KEY="$anon" \
exec node_modules/.bin/pnpm --filter @faunosteo/app exec vite --port 5173 --strictPort
+10
View File
@@ -0,0 +1,10 @@
#!/usr/bin/env bash
# Supabase CLI with the DEV origin exported: supabase/config.toml reads the
# API external URL, the site URL and Studio's API URL through env(), so every
# CLI call (start, stop, status, db reset, test db, gen types) must see them,
# or the literal "env(...)" text lands in the running services.
# pnpm supabase <args> · pnpm db:start · FAUNOSTEO_DEV_HOST=10.0.0.5 pnpm db:start
set -euo pipefail
cd "$(dirname "$0")/.."
. scripts/dev-env.sh
exec node_modules/.bin/supabase "$@"