fix(mobile): default h5 dev proxy to local backend on 8080

Bare npm run dev (including hosted preview sessions) has no portless
route, so the previous default target https://wygj-api.localhost was
unreachable and every API call failed with HTTP 500. scripts/dev.sh now
passes VITE_PROXY_TARGET explicitly, keeping the portless flow intact.
This commit is contained in:
2026-07-20 13:55:50 +08:00
parent 6f2159db73
commit 5184672b61
2 changed files with 4 additions and 2 deletions
+3 -1
View File
@@ -4,7 +4,9 @@ import uniPlugin from '@dcloudio/vite-plugin-uni';
const uni = typeof uniPlugin === 'function' ? uniPlugin : uniPlugin.default;
const devPort = Number(process.env.PORT) || 5175;
const devHost = process.env.HOST || '0.0.0.0';
const proxyTarget = process.env.VITE_PROXY_TARGET || 'https://wygj-api.localhost';
// 裸跑 npm run dev(如 Kimi Work 预览)时代理到本地 8080 后端;
// 走 portless(scripts/dev.sh)时由 VITE_PROXY_TARGET 显式指向 https://wygj-api.localhost
const proxyTarget = process.env.VITE_PROXY_TARGET || 'http://127.0.0.1:8080';
// 代理到线上等已带 /dev-api 前缀的网关时,设 VITE_PROXY_KEEP_PREFIX=1 保留前缀
const keepProxyPrefix = process.env.VITE_PROXY_KEEP_PREFIX === '1';
+1 -1
View File
@@ -249,7 +249,7 @@ PIDS+=("$!")
if using_portless_mobile; then
portless alias --remove wygj-mobile-uni >/dev/null 2>&1 || true
portless run --name wygj-mobile-uni --force npm --prefix mobile-uni run dev &
VITE_PROXY_TARGET="${VITE_PROXY_TARGET:-https://wygj-api.localhost}" portless run --name wygj-mobile-uni --force npm --prefix mobile-uni run dev &
else
./scripts/dev-mobile.sh &
fi