From 99d17b1898211b5fee833e353b96bf7d1649a6ee Mon Sep 17 00:00:00 2001 From: Alan Weinstock Date: Wed, 27 May 2026 16:30:43 -0700 Subject: [PATCH] feat: prefer static dist over Vite dev server in _start_web manage.sh now checks for frontend/dist/index.html at startup. If present, uses Python http.server (no host-blocking, production mode). Falls back to Vite dev server only when dist is absent. Fixes Vite's "Blocked request. This host is not allowed" error when proxied behind Caddy at menagerie.circuitforge.tech. --- manage.sh | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/manage.sh b/manage.sh index fcb10b2..155576b 100755 --- a/manage.sh +++ b/manage.sh @@ -80,11 +80,19 @@ _start_web() { warn "Port :${WEB_PORT} already in use by another process — stop it first or change WEB_PORT" return fi - info "Starting web on :${WEB_PORT}..." - cd frontend - npm run dev >> "$LOG_WEB" 2>&1 & + # Prefer the pre-built dist (production) over Vite dev server. + # Run `./manage.sh build` first to produce frontend/dist/. + if [[ -f "frontend/dist/index.html" ]]; then + info "Starting web on :${WEB_PORT} (static dist — production mode)..." + conda run --no-capture-output -n "$CONDA_ENV" \ + python -m http.server "$WEB_PORT" --directory frontend/dist >> "$LOG_WEB" 2>&1 & + else + info "Starting web on :${WEB_PORT} (Vite dev server — no dist found)..." + cd frontend + npm run dev >> "$LOG_WEB" 2>&1 & + cd "$REPO_DIR" + fi echo $! > "$PID_WEB" - cd "$REPO_DIR" local i=0 while ! _port_open "$WEB_PORT" && (( i++ < 20 )); do sleep 0.5; done if _port_open "$WEB_PORT"; then