From 2dc63235543b660276f5ea5308e57e132efad642 Mon Sep 17 00:00:00 2001 From: WanWanYun Date: Tue, 11 Nov 2025 23:54:22 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D:=20=E7=A7=BB=E9=99=A4API?= =?UTF-8?q?=E5=9C=B0=E5=9D=80=E7=A1=AC=E7=BC=96=E7=A0=81=EF=BC=8C=E7=BB=9F?= =?UTF-8?q?=E4=B8=80=E4=BD=BF=E7=94=A8nginx=E4=BB=A3=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修复frontend/app.js中的localhost:40001硬编码 - 修复frontend/share.html中的localhost:40001硬编码 - 所有API请求现在统一通过nginx代理访问 - 支持任意端口号部署,无需修改前端代码 --- frontend/app.js | 6 ++---- frontend/share.html | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/frontend/app.js b/frontend/app.js index ef13a58..7cb4912 100644 --- a/frontend/app.js +++ b/frontend/app.js @@ -4,10 +4,8 @@ createApp({ data() { return { // API配置 - // API配置 - 动态适配localhost或生产环境 - apiBase: window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1' - ? 'http://localhost:40001' - : window.location.protocol + '//' + window.location.host, + // API配置 - 通过nginx代理访问 + apiBase: window.location.protocol + '//' + window.location.host, // 用户状态 isLoggedIn: false, diff --git a/frontend/share.html b/frontend/share.html index 5db22c5..ba0942e 100644 --- a/frontend/share.html +++ b/frontend/share.html @@ -583,10 +583,8 @@ createApp({ data() { return { - // API配置 - 动态适配localhost或生产环境 - apiBase: window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1' - ? 'http://localhost:40001' - : window.location.protocol + '//' + window.location.host, + // API配置 - 通过nginx代理访问 + apiBase: window.location.protocol + '//' + window.location.host, shareCode: '', password: '', needPassword: false,