| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214 |
- 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
|