Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Point worktree servers at their own host for generated URLs

Damian Legawiec02420d5bf460
diff --git a/scripts/worktree/lib.sh b/scripts/worktree/lib.sh
index 6d0320f536..795b5c7be9 100755
--- a/scripts/worktree/lib.sh
+++ b/scripts/worktree/lib.sh
@@ -74,6 +74,8 @@ rails_name() { echo "$(branch_slug).spree"; }
dashboard_name() { echo "admin.$(branch_slug).spree"; }
rails_url() { echo "https://$(rails_name).localhost$(url_suffix)"; }
dashboard_url() { echo "https://$(dashboard_name).localhost$(url_suffix)"; }
+# RAILS_HOST wants a bare host with an optional port, no scheme.
+rails_host() { echo "$(rails_name).localhost$(url_suffix)"; }
port_free() { ! lsof -iTCP:"$1" -sTCP:LISTEN -n -P >/dev/null 2>&1; }
diff --git a/scripts/worktree/setup.sh b/scripts/worktree/setup.sh
index 18eac605bb..1247b4c363 100755
--- a/scripts/worktree/setup.sh
+++ b/scripts/worktree/setup.sh
@@ -24,6 +24,7 @@ SECRET_KEY_BASE=$(openssl rand -hex 64)
DATABASE_NAME=$(db_name)
DATABASE_NAME_TEST=$(test_db_name)
SPREE_DASHBOARD_URL=$(dashboard_url)
+RAILS_HOST=$(rails_host)
EOF
fi
@@ -33,6 +34,12 @@ if ! grep -q '^SPREE_DASHBOARD_URL=' server/.env; then
printf 'SPREE_DASHBOARD_URL=%s\n' "$(dashboard_url)" >> server/.env
fi
+# Backfill likewise: without it, attachment URLs in API payloads fall back to
+# the store's seeded `localhost:3000`, so dashboard images 404.
+if ! grep -q '^RAILS_HOST=' server/.env; then
+ printf 'RAILS_HOST=%s\n' "$(rails_host)" >> server/.env
+fi
+
require_current_starter
if ! db_exists "$(db_name)"; then