Skip to content

Commit 2c414ae

Browse files
committed
fix(前端配置): 自动设置API基础URL以支持跨设备访问
将硬编码的API基础URL改为动态获取当前域名和端口,使前端在不同网络环境下都能正确访问后端服务。
1 parent a7eff2f commit 2c414ae

File tree

1 file changed

+2
-2
lines changed
  • file_classification_webapi/static/js

1 file changed

+2
-2
lines changed

file_classification_webapi/static/js/config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// API基础URL
2-
const BASE_URL = 'http://127.0.0.1:8082';
1+
// API基础URL - 自动获取当前访问的域名和端口,以支持跨设备访问
2+
const BASE_URL = window.location.protocol + '//' + window.location.hostname + (window.location.port ? ':' + window.location.port : '');
33

44
// 导出配置
55
window.APP_CONFIG = {

0 commit comments

Comments
 (0)