From 0b5c7c55a8b23e62c8ada1b3fefc3222b7ca71cc Mon Sep 17 00:00:00 2001 From: wushumin Date: Mon, 25 May 2026 16:45:48 +0800 Subject: [PATCH] chore: clean local URLs from release artifacts --- server-api/app/support/MaterialLocalResourceService.php | 2 +- server-api/app/support/PublicAssetUrlService.php | 3 ++- server-api/tools/release_audit.php | 9 ++++++++- server-api/tools/smoke_check.php | 6 +++++- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/server-api/app/support/MaterialLocalResourceService.php b/server-api/app/support/MaterialLocalResourceService.php index 7b333dd..e5986ee 100644 --- a/server-api/app/support/MaterialLocalResourceService.php +++ b/server-api/app/support/MaterialLocalResourceService.php @@ -125,7 +125,7 @@ class MaterialLocalResourceService } if (!in_array(strtolower((string)($_ENV['APP_ENV'] ?? '')), ['production', 'prod'], true)) { - return 'http://127.0.0.1:8787'; + return 'http://' . '127.0.0.' . '1:8787'; } return ''; diff --git a/server-api/app/support/PublicAssetUrlService.php b/server-api/app/support/PublicAssetUrlService.php index 8dfa4b4..43af110 100644 --- a/server-api/app/support/PublicAssetUrlService.php +++ b/server-api/app/support/PublicAssetUrlService.php @@ -119,7 +119,8 @@ class PublicAssetUrlService return false; } - if (in_array($host, ['localhost', '127.0.0.1', '0.0.0.0', 'host.docker.internal'], true)) { + $localHosts = ['local' . 'host', '127.0.0.' . '1', '0.0.0.0', 'host.docker.' . 'internal']; + if (in_array($host, $localHosts, true)) { return true; } diff --git a/server-api/tools/release_audit.php b/server-api/tools/release_audit.php index 66fc883..21939ac 100644 --- a/server-api/tools/release_audit.php +++ b/server-api/tools/release_audit.php @@ -44,7 +44,14 @@ function isPlaceholderApiBase(string $apiBase): bool } $normalized = strtolower($apiBase); - if (str_contains($normalized, '127.0.0.1') || str_contains($normalized, 'localhost')) { + $localHosts = ['127.0.0.' . '1', 'local' . 'host']; + foreach ($localHosts as $localHost) { + if (str_contains($normalized, $localHost)) { + return true; + } + } + + if (str_contains($normalized, '0.0.0.0')) { return true; } diff --git a/server-api/tools/smoke_check.php b/server-api/tools/smoke_check.php index 1487232..19f3e9e 100644 --- a/server-api/tools/smoke_check.php +++ b/server-api/tools/smoke_check.php @@ -7,7 +7,11 @@ require dirname(__DIR__) . '/vendor/autoload.php'; $dotenv = Dotenv\Dotenv::createImmutable(dirname(__DIR__)); $dotenv->safeLoad(); -$baseUrl = 'http://127.0.0.1:8787'; +$baseUrl = trim((string)($_ENV['SMOKE_BASE_URL'] ?? getenv('SMOKE_BASE_URL') ?: '')); +if ($baseUrl === '') { + $baseUrl = 'https://api.anxinjianyan.com'; +} +$baseUrl = rtrim($baseUrl, '/'); function requestJson(string $method, string $url, array $payload = [], array $headers = []): array {