From bf6ddcb933ed2545ecdcaa74e767dbc30826ca3f Mon Sep 17 00:00:00 2001 From: Jeremy Daer Date: Tue, 16 Dec 2025 09:54:53 -0800 Subject: [PATCH] Add --tailscale flag to bin/dev for remote access (#2168) Enables sharing dev sites over Tailscale serve. Uses port convention 4xxxx (prepending 4 to the dev port, echoing TLS 443) so multiple apps can run simultaneously on different ports. Usage: bin/dev --tailscale --- bin/dev | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/bin/dev b/bin/dev index d01747dd3..21ef0eeeb 100755 --- a/bin/dev +++ b/bin/dev @@ -1,8 +1,13 @@ #!/usr/bin/env sh -bin/rails runner - </dev/null 2>&1; then + echo "Error: tailscale not found" >&2 + exit 1 + fi + + TS_STATUS=$(tailscale status --self --json 2>&1) + if [ $? -ne 0 ]; then + echo "Error: tailscale not logged in" >&2 + exit 1 + fi + + TS_HOSTNAME=$(echo "$TS_STATUS" | jq -r '.Self.DNSName | rtrimstr(".")') + TS_PORT="4$PORT" + + stop_tailscale() { tailscale serve --https=$TS_PORT off >/dev/null 2>&1; } + trap stop_tailscale EXIT INT TERM + + tailscale serve --bg --https=$TS_PORT "http://fizzy.localhost:$PORT" >/dev/null 2>&1 + echo "Login with david@example.com to: https://$TS_HOSTNAME:$TS_PORT/" +else + echo "Login with david@example.com to: http://fizzy.localhost:$PORT/" +fi + +./bin/rails server -p $PORT