From 1a5aac99989af463cd165f0a3f546f2b13608fd2 Mon Sep 17 00:00:00 2001 From: bujinyuan Date: Fri, 13 Mar 2026 16:34:28 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E4=BF=AE=E6=94=B9=E5=9C=B0=E5=9D=80?= =?UTF-8?q?=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin/vite.config.js | 1 + frontend/src/utils/request.js | 3 ++- frontend/vite.config.js | 3 +++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/admin/vite.config.js b/admin/vite.config.js index 521922e..aa67492 100644 --- a/admin/vite.config.js +++ b/admin/vite.config.js @@ -10,6 +10,7 @@ export default defineConfig({ } }, server: { + host: '0.0.0.0', port: 3100, proxy: { '/api': { diff --git a/frontend/src/utils/request.js b/frontend/src/utils/request.js index 5767deb..8c6dad6 100644 --- a/frontend/src/utils/request.js +++ b/frontend/src/utils/request.js @@ -13,8 +13,9 @@ import { getToken, removeToken } from './storage' // 基础 URL 配置,根据环境自动切换 +// 开发环境使用 window.location.hostname 动态获取主机名,支持局域网 IP 访问 const BASE_URL = process.env.NODE_ENV === 'development' - ? 'http://localhost:8085' + ? `http://${window.location.hostname}:8085` : '' // 生产环境由 Nginx 反向代理,使用相对路径 // 请求超时时间(毫秒) diff --git a/frontend/vite.config.js b/frontend/vite.config.js index 6f7b2c3..2bbd42b 100644 --- a/frontend/vite.config.js +++ b/frontend/vite.config.js @@ -5,4 +5,7 @@ export default defineConfig({ plugins: [ uni(), ], + server: { + host: '0.0.0.0', + }, })