From 797feff8c2947e4454130121b6d6088b20589404 Mon Sep 17 00:00:00 2001 From: zhangjf Date: Sun, 22 Feb 2026 22:24:20 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20fund-gateway=E5=A2=9E=E5=8A=A0/fund=20c?= =?UTF-8?q?ontext=20path?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修改内容: 1. fund-gateway/application.yml: - 所有路由Path添加/fund前缀 - StripPrefix从1改为2(剥离/fund和模块名两级) - 例:/fund/sys/... -> 转发到 /api/v1/sys/... 2. 前端API配置: - fund-admin/src/api/request.ts: baseURL改为'/fund' - fund-mobile/src/api/request.ts: baseURL改为'/fund' 3. Nginx部署脚本: - 添加/fund/路径代理配置 - 保留/api/代理兼容旧版 API调用示例: - 旧版:/sys/auth/login - 新版:/fund/sys/auth/login 网关路由: - /fund/sys/** -> lb://fund-sys/api/v1/sys/** - /fund/cust/** -> lb://fund-cust/api/v1/cust/** - ... --- fund-admin/src/api/request.ts | 2 +- .../src/main/resources/application.yml | 32 +++++++++---------- fund-mobile/src/api/request.ts | 2 +- scripts/deploy-frontend-nginx.sh | 19 ++++++++++- scripts/env.properties | 4 +-- 5 files changed, 38 insertions(+), 21 deletions(-) diff --git a/fund-admin/src/api/request.ts b/fund-admin/src/api/request.ts index 3f8568f..109db53 100644 --- a/fund-admin/src/api/request.ts +++ b/fund-admin/src/api/request.ts @@ -3,7 +3,7 @@ import { ElMessage } from 'element-plus' // 创建axios实例 const service: AxiosInstance = axios.create({ - baseURL: '', + baseURL: '/fund', timeout: 15000, headers: { 'Content-Type': 'application/json' diff --git a/fund-gateway/src/main/resources/application.yml b/fund-gateway/src/main/resources/application.yml index 332b3f5..ba3a9eb 100644 --- a/fund-gateway/src/main/resources/application.yml +++ b/fund-gateway/src/main/resources/application.yml @@ -63,65 +63,65 @@ spring: - id: fund-sys uri: lb://fund-sys predicates: - - Path=/sys/** + - Path=/fund/sys/** filters: - - StripPrefix=1 + - StripPrefix=2 # 客户管理服务 - id: fund-cust uri: lb://fund-cust predicates: - - Path=/cust/** + - Path=/fund/cust/** filters: - - StripPrefix=1 + - StripPrefix=2 # 项目管理服务 - id: fund-proj uri: lb://fund-proj predicates: - - Path=/proj/** + - Path=/fund/proj/** filters: - - StripPrefix=1 + - StripPrefix=2 # 用款申请服务 - id: fund-req uri: lb://fund-req predicates: - - Path=/req/** + - Path=/fund/req/** filters: - - StripPrefix=1 + - StripPrefix=2 # 支出管理服务 - id: fund-exp uri: lb://fund-exp predicates: - - Path=/exp/** + - Path=/fund/exp/** filters: - - StripPrefix=1 + - StripPrefix=2 # 收款管理服务 - id: fund-receipt uri: lb://fund-receipt predicates: - - Path=/receipt/** + - Path=/fund/receipt/** filters: - - StripPrefix=1 + - StripPrefix=2 # 报表服务 - id: fund-report uri: lb://fund-report predicates: - - Path=/report/** + - Path=/fund/report/** filters: - - StripPrefix=1 + - StripPrefix=2 # 文件服务 - id: fund-file uri: lb://fund-file predicates: - - Path=/file/** + - Path=/fund/file/** filters: - - StripPrefix=1 + - StripPrefix=2 # 多租户路由配置 tenant: diff --git a/fund-mobile/src/api/request.ts b/fund-mobile/src/api/request.ts index d2a4c0b..7b9b96c 100644 --- a/fund-mobile/src/api/request.ts +++ b/fund-mobile/src/api/request.ts @@ -1,7 +1,7 @@ import axios from 'axios' const request = axios.create({ - baseURL: '', + baseURL: '/fund', timeout: 15000, headers: { 'Content-Type': 'application/json' diff --git a/scripts/deploy-frontend-nginx.sh b/scripts/deploy-frontend-nginx.sh index c37d4d5..ca025bd 100755 --- a/scripts/deploy-frontend-nginx.sh +++ b/scripts/deploy-frontend-nginx.sh @@ -96,7 +96,24 @@ server { add_header Cache-Control "public, immutable"; } - # API代理到网关 + # API代理到网关(/fund前缀) + location /fund/ { + proxy_pass http://${gateway_host}/fund/; + proxy_set_header Host \$host; + proxy_set_header X-Real-IP \$remote_addr; + proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto \$scheme; + + # 超时配置 + proxy_connect_timeout 60s; + proxy_send_timeout 60s; + proxy_read_timeout 60s; + + # 文件上传大小限制 + client_max_body_size 100m; + } + + # 兼容旧版/api代理(可选,逐步迁移后可删除) location /api/ { proxy_pass http://${gateway_host}/; proxy_set_header Host \$host; diff --git a/scripts/env.properties b/scripts/env.properties index 63bae98..c971e69 100644 --- a/scripts/env.properties +++ b/scripts/env.properties @@ -57,8 +57,8 @@ COS_BUCKET_HOST=https://test-1308258046.cos.ap-beijing.myqcloud.com # -------------------------------------------- # 文件上传配置 # -------------------------------------------- -FILE_UPLOAD_MAX_SIZE=50MB -FILE_UPLOAD_MAX_REQUEST_SIZE=100MB +FILE_UPLOAD_MAX_SIZE=52428800 +FILE_UPLOAD_MAX_REQUEST_SIZE=52428800 FILE_STORAGE_PATH=./uploads FILE_STORAGE_MAX_BYTES=52428800