up
This commit is contained in:
+10
-3
@@ -1,6 +1,13 @@
|
||||
// Python 后端 API 客户端 — 自动适配局域网 IP
|
||||
// 前端 JS 在浏览器中运行时,API 用当前页面的 hostname(端口 8000)
|
||||
const API_BASE = `http://${window.location.hostname}:8000`;
|
||||
// Python 后端 API 客户端
|
||||
// 生产环境:同源反代,用相对路径
|
||||
// 开发环境:Vite 3015 → 后端 8000,显式跨域
|
||||
const API_BASE = (() => {
|
||||
const { hostname, port } = window.location;
|
||||
if (port === '3015') {
|
||||
return `http://${hostname}:8000`;
|
||||
}
|
||||
return '';
|
||||
})();
|
||||
|
||||
export function getApiBaseUrl(): string {
|
||||
return API_BASE;
|
||||
|
||||
Reference in New Issue
Block a user