fix(persona-studio): 修复「我要开发」后端连接失败 [ZY-FIX]

Co-authored-by: qinfendebingshuo <207279273+qinfendebingshuo@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2026-03-15 06:55:53 +00:00
parent 73db98300c
commit b913d119e4
3 changed files with 15 additions and 3 deletions

View File

@ -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 前端 ──

View File

@ -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 ---- */

View File

@ -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) {