fix: 修复网关路由配置,添加PrefixPath补全API路径

问题:
- StripPrefix=2 后路径缺少 /api/v1 前缀
- 健康检查路径不正确,无法访问

修改:
1. application.yml: 所有路由添加 PrefixPath=/api/v1
2. TenantGatewayFilter: 更新白名单健康检查路径
3. TokenAuthFilter: 更新白名单健康检查路径

路由流程示例:
- 登录: /fund/sys/auth/login
  → StripPrefix=2 → /auth/login
  → PrefixPath=/api/v1 → /api/v1/auth/login ✓

- 健康检查: /fund/sys/sys/health
  → StripPrefix=2 → /sys/health
  → PrefixPath=/api/v1 → /api/v1/sys/health ✓

注意:健康检查路径需要重复模块名
- /fund/{module}/{module}/health
This commit is contained in:
zhangjf 2026-02-22 22:48:32 +08:00
parent 92d8234fcb
commit e6f3f85581
3 changed files with 29 additions and 19 deletions

View File

@ -39,18 +39,19 @@ public class TenantGatewayFilter implements GlobalFilter, Ordered {
// 白名单路径不需要X-Tenant-Id
// 注意路径是网关接收的原始请求路径/fund前缀
// 健康检查路径需要包含模块名两次一次用于路由一次用于服务路径
private static final List<String> TENANT_ID_WHITE_LIST = Arrays.asList(
"/fund/sys/auth/login", // 登录接口
"/fund/sys/auth/logout", // 登出接口
"/actuator/health", // 网关健康检查/fund前缀
"/fund/sys/health", // 系统服务健康检查
"/fund/cust/health", // 客户服务健康检查
"/fund/proj/health", // 项目服务健康检查
"/fund/exp/health", // 支出服务健康检查
"/fund/receipt/health", // 收款服务健康检查
"/fund/report/health", // 报表服务健康检查
"/fund/req/health", // 请求服务健康检查
"/fund/file/health" // 文件服务健康检查
"/fund/sys/sys/health", // 系统服务健康检查 (/api/v1/sys/health)
"/fund/cust/cust/health", // 客户服务健康检查 (/api/v1/cust/health)
"/fund/proj/proj/health", // 项目服务健康检查 (/api/v1/proj/health)
"/fund/exp/exp/health", // 支出服务健康检查 (/api/v1/exp/health)
"/fund/receipt/receipt/health", // 收款服务健康检查 (/api/v1/receipt/health)
"/fund/report/report/health", // 报表服务健康检查 (/api/v1/report/health)
"/fund/req/req/health", // 请求服务健康检查 (/api/v1/req/health)
"/fund/file/file/health" // 文件服务健康检查 (/api/v1/file/health)
);
private final ObjectMapper objectMapper = new ObjectMapper();

View File

@ -40,16 +40,17 @@ public class TokenAuthFilter implements GlobalFilter, Ordered {
// 白名单路径(不需要token验证)
// 注意路径是网关接收的原始请求路径/fund前缀
// 健康检查路径需要包含模块名两次一次用于路由一次用于服务路径
private static final List<String> WHITE_LIST = Arrays.asList(
"/fund/sys/auth/login",
"/fund/sys/health",
"/fund/cust/health",
"/fund/proj/health",
"/fund/exp/health",
"/fund/receipt/health",
"/fund/report/health",
"/fund/req/health",
"/fund/file/health"
"/fund/sys/sys/health",
"/fund/cust/cust/health",
"/fund/proj/proj/health",
"/fund/exp/exp/health",
"/fund/receipt/receipt/health",
"/fund/report/report/health",
"/fund/req/req/health",
"/fund/file/file/health"
);
private final ReactiveTokenService reactiveTokenService;

View File

@ -66,6 +66,7 @@ spring:
- Path=/fund/sys/**
filters:
- StripPrefix=2
- PrefixPath=/api/v1
# 客户管理服务
- id: fund-cust
@ -74,6 +75,7 @@ spring:
- Path=/fund/cust/**
filters:
- StripPrefix=2
- PrefixPath=/api/v1
# 项目管理服务
- id: fund-proj
@ -82,6 +84,7 @@ spring:
- Path=/fund/proj/**
filters:
- StripPrefix=2
- PrefixPath=/api/v1
# 用款申请服务
- id: fund-req
@ -90,6 +93,7 @@ spring:
- Path=/fund/req/**
filters:
- StripPrefix=2
- PrefixPath=/api/v1
# 支出管理服务
- id: fund-exp
@ -98,6 +102,7 @@ spring:
- Path=/fund/exp/**
filters:
- StripPrefix=2
- PrefixPath=/api/v1
# 收款管理服务
- id: fund-receipt
@ -106,6 +111,7 @@ spring:
- Path=/fund/receipt/**
filters:
- StripPrefix=2
- PrefixPath=/api/v1
# 报表服务
- id: fund-report
@ -114,6 +120,7 @@ spring:
- Path=/fund/report/**
filters:
- StripPrefix=2
- PrefixPath=/api/v1
# 文件服务
- id: fund-file
@ -122,6 +129,7 @@ spring:
- Path=/fund/file/**
filters:
- StripPrefix=2
- PrefixPath=/api/v1
# 多租户路由配置
tenant: