From 92307a9f9750cea406df606df604c7bff2ceefda Mon Sep 17 00:00:00 2001 From: "2569718930@qq.com" <2569718930@qq.com> Date: Wed, 3 Jun 2026 02:13:02 +0800 Subject: [PATCH] fix: force frontend proxy to internal backend --- deploy.sh | 1 + docker-compose.yml | 2 +- tests/test_deployment_runtime_config.py | 19 +++++++++++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/deploy.sh b/deploy.sh index f72e151a..8dc12d1d 100644 --- a/deploy.sh +++ b/deploy.sh @@ -73,6 +73,7 @@ compose_up_retry() { } export IMAGE_TAG="$NEW_TAG" +export POLYWEATHER_API_BASE_URL="${POLYWEATHER_FRONTEND_INTERNAL_API_BASE_URL:-http://polyweather_web:8000}" pull_ok=0 for pull_attempt in $(seq 1 6); do docker compose pull && pull_ok=1 && break diff --git a/docker-compose.yml b/docker-compose.yml index adc7bbb5..106c1c04 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -69,7 +69,7 @@ services: NEXT_PUBLIC_SUPABASE_URL: ${NEXT_PUBLIC_SUPABASE_URL} NEXT_PUBLIC_WALLETCONNECT_POLYGON_RPC_URL: ${NEXT_PUBLIC_WALLETCONNECT_POLYGON_RPC_URL:-https://polygon-bor-rpc.publicnode.com} NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID: ${NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID:-} - POLYWEATHER_API_BASE_URL: ${POLYWEATHER_API_BASE_URL:-http://polyweather_web:8000} + POLYWEATHER_API_BASE_URL: http://polyweather_web:8000 POLYWEATHER_AUTH_ENABLED: ${POLYWEATHER_AUTH_ENABLED:-true} POLYWEATHER_AUTH_REQUIRED: ${POLYWEATHER_AUTH_REQUIRED:-true} POLYWEATHER_OPS_ADMIN_EMAILS: ${POLYWEATHER_OPS_ADMIN_EMAILS:-} diff --git a/tests/test_deployment_runtime_config.py b/tests/test_deployment_runtime_config.py index 62edee6b..2519c606 100644 --- a/tests/test_deployment_runtime_config.py +++ b/tests/test_deployment_runtime_config.py @@ -160,6 +160,25 @@ def test_docker_compose_keeps_polyweather_ports_on_loopback(): assert "\n - 8000:8000" not in compose +def test_frontend_proxy_uses_internal_backend_url_not_public_site(): + compose = (ROOT / "docker-compose.yml").read_text(encoding="utf-8") + script = (ROOT / "deploy.sh").read_text(encoding="utf-8") + frontend_block = compose.split(" polyweather_frontend:", 1)[1].split( + "\n polyweather_web:", + 1, + )[0] + + assert "POLYWEATHER_API_BASE_URL: http://polyweather_web:8000" in frontend_block + assert ( + "POLYWEATHER_API_BASE_URL: ${POLYWEATHER_API_BASE_URL:-http://polyweather_web:8000}" + not in frontend_block + ) + assert 'export POLYWEATHER_API_BASE_URL="${POLYWEATHER_FRONTEND_INTERNAL_API_BASE_URL:-http://polyweather_web:8000}"' in script + assert script.index("export POLYWEATHER_API_BASE_URL=") < script.rindex( + "validate_frontend_api_base_url" + ) + + def test_web_container_raises_open_file_limit_for_sse_and_proxy_load(): compose = (ROOT / "docker-compose.yml").read_text(encoding="utf-8") web_block = compose.split(" polyweather_web:", 1)[1].split(