diff --git a/src/utils/tools.ts b/src/utils/tools.ts index 8ca89147cefa14dc09d3cc338fbaa8826551c6a4..78f3fb33bfb98c77577b6db7e9718654e6c8227b 100644 --- a/src/utils/tools.ts +++ b/src/utils/tools.ts @@ -96,5 +96,7 @@ export async function getBaseProxyUrl(): Promise { if (window.location.hostname === 'localhost') { return ''; } - return import.meta.env.VITE_BASE_PROXY_URL; + // VITE_BASE_PROXY_URL 未定义时返回空字符串 + const viteProxyUrl = import.meta.env.VITE_BASE_PROXY_URL; + return typeof viteProxyUrl === 'string' && viteProxyUrl ? viteProxyUrl : ''; }