server: port: 8083 spring: application: name: gateway cloud: gateway: discovery: locator: enabled: false # 统一去重响应头,避免下游服务与网关同时添加CORS头导致浏览器报多值错误 default-filters: # 处理可能出现的重复CORS响应头,只保留最后一个(通常为网关globalcors写入的值) - DedupeResponseHeader=Access-Control-Allow-Origin Access-Control-Allow-Credentials, RETAIN_LAST routes: # 管理端服务路由(优先级最高) - id: admin-route uri: http://localhost:8088 predicates: - Path=/admin/** filters: - StripPrefix=0 # 管理端API路由(公告等功能) - id: admin-api-route uri: http://localhost:8088 predicates: - Path=/api/admin/** filters: - StripPrefix=0 # WebSocket聊天服务路由 - id: websocket-route uri: http://localhost:1004 predicates: - Path=/ws/chat/** filters: - StripPrefix=0 # 在线状态API路由 - id: online-api-route uri: http://localhost:1004 predicates: - Path=/api/online/** filters: - StripPrefix=0 # IM服务路由(腾讯云IM相关) - id: im-api-route uri: http://localhost:1004 predicates: - Path=/api/im/** filters: - StripPrefix=0 metadata: response-timeout: 5000 # 好友服务路由(拉黑等功能) - id: chatfriend-api-route uri: http://localhost:1004 predicates: - Path=/api/chatfriend/** filters: - StripPrefix=0 # 语音上传服务路由 - id: voice-api-route uri: http://localhost:1004 predicates: - Path=/api/voice/** filters: - StripPrefix=0 # 聊天REST API路由 - id: chat-api-route uri: http://localhost:1004 predicates: - Path=/api/chat/** filters: - StripPrefix=0 # 匹配服务路由(必须在 /api/** 之前,避免被覆盖) - id: match-route uri: http://127.0.0.1:1003 predicates: - Path=/match/** filters: - StripPrefix=0 # 首页服务路由 # 公告服务路由(HomePage服务) - id: announcement-route uri: http://localhost:8081 predicates: - Path=/api/announcement/** filters: - StripPrefix=0 # 动态服务路由(必须在homepage-route之前) - id: dynamic-route uri: http://localhost:8086 predicates: - Path=/api/dynamic/** filters: - StripPrefix=0 # 动态媒体文件路由 - id: dynamic-media-route uri: http://localhost:8086 predicates: - Path=/media/** filters: - StripPrefix=0 # 系统消息(小程序)路由 -> dynamic 服务 - id: system-message-route uri: http://localhost:8086 predicates: - Path=/api/message/system/** filters: - StripPrefix=0 # 系统消息接口(小程序系统通知) - id: system-message-all-route uri: http://localhost:8086 predicates: - Path=/api/message/** filters: - StripPrefix=0 # Essential服务路由(用户信息等基础服务) - id: essential-route uri: http://localhost:1005 predicates: - Path=/api/user/** filters: - StripPrefix=0 # Essential服务-反馈路由 - id: essential-feedback-route uri: http://localhost:1005 predicates: - Path=/api/feedback/** filters: - StripPrefix=0 # Essential服务-择偶要求路由 - id: essential-partner-requirement-route uri: http://localhost:1005 predicates: - Path=/api/partner-requirement/** filters: - StripPrefix=0 # 积分商城路由(admin服务) - id: points-mall-route uri: http://localhost:8088 predicates: - Path=/api/points/** filters: - StripPrefix=1 # 课程服务路由(homePage服务) - id: course-route uri: http://localhost:8081 predicates: - Path=/api/course/** filters: - StripPrefix=0 # 课程订单服务路由(Essential服务-微信支付) - id: course-order-route uri: http://localhost:1005 predicates: - Path=/api/course-order/** filters: - StripPrefix=0 # 首页服务路由(兜底路由) - id: homepage-route uri: http://localhost:8081 predicates: - Path=/api/** filters: - StripPrefix=0 # WebSocket支持配置 websocket: enabled: true # 全局CORS配置 globalcors: corsConfigurations: '[/**]': allowedOriginPatterns: - "*" # - "https://*.your-domain.com" # 允许所有域名(开发环境) allowedMethods: - GET - POST - PUT - DELETE - OPTIONS allowedHeaders: "*" allowCredentials: true maxAge: 3600 # 日志配置 logging: level: org.springframework.cloud.gateway: DEBUG # 开启网关调试日志 com.zhentao: DEBUG # 开启项目调试日志 org.springframework.web: INFO