From b913d119e42b54e8278f0da2740fae1204981af3 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 15 Mar 2026 06:55:53 +0000 Subject: [PATCH] =?UTF-8?q?fix(persona-studio):=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E3=80=8C=E6=88=91=E8=A6=81=E5=BC=80=E5=8F=91=E3=80=8D=E5=90=8E?= =?UTF-8?q?=E7=AB=AF=E8=BF=9E=E6=8E=A5=E5=A4=B1=E8=B4=A5=20[ZY-FIX]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: qinfendebingshuo <207279273+qinfendebingshuo@users.noreply.github.com> --- persona-studio/backend/server.js | 12 +++++++++++- persona-studio/frontend/chat.js | 3 ++- persona-studio/frontend/index.html | 3 ++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/persona-studio/backend/server.js b/persona-studio/backend/server.js index f8c4ea12..ae561b8f 100644 --- a/persona-studio/backend/server.js +++ b/persona-studio/backend/server.js @@ -12,7 +12,17 @@ const apikeyRoutes = require('./routes/apikey'); const previewRoutes = require('./routes/preview'); const app = express(); -app.use(cors()); +app.use(cors({ + origin: [ + 'http://localhost:3002', + 'http://127.0.0.1:3002', + 'http://8.155.62.235', + 'https://guanghulab.com', + 'http://guanghulab.com', + 'https://qinfendebingshuo.github.io' + ], + credentials: true +})); app.use(express.json({ limit: '2mb' })); // ── 静态文件:persona-studio 前端 ── diff --git a/persona-studio/frontend/chat.js b/persona-studio/frontend/chat.js index 05158e9f..b4a38bf7 100644 --- a/persona-studio/frontend/chat.js +++ b/persona-studio/frontend/chat.js @@ -15,7 +15,8 @@ const API_BASE = (function () { if (location.hostname === 'localhost' || location.hostname === '127.0.0.1') { return 'http://localhost:3002'; } - return 'https://guanghulab.com'; + // 非本地环境统一使用当前域名 + 协议,走 Nginx 转发 + return location.protocol + '//' + location.host; })(); /* ---- State ---- */ diff --git a/persona-studio/frontend/index.html b/persona-studio/frontend/index.html index 1835efe8..d9299f13 100644 --- a/persona-studio/frontend/index.html +++ b/persona-studio/frontend/index.html @@ -152,7 +152,8 @@ if (location.hostname === 'localhost' || location.hostname === '127.0.0.1') { return 'http://localhost:3002'; } - return 'https://guanghulab.com'; + // 非本地环境统一使用当前域名 + 协议,走 Nginx 转发 + return location.protocol + '//' + location.host; } function normalizeApiBase(base) {