application.yml 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. server:
  2. port: 8083
  3. spring:
  4. application:
  5. name: gateway
  6. cloud:
  7. gateway:
  8. discovery:
  9. locator:
  10. enabled: false
  11. # 统一去重响应头,避免下游服务与网关同时添加CORS头导致浏览器报多值错误
  12. default-filters:
  13. # 处理可能出现的重复CORS响应头,只保留最后一个(通常为网关globalcors写入的值)
  14. - DedupeResponseHeader=Access-Control-Allow-Origin Access-Control-Allow-Credentials, RETAIN_LAST
  15. routes:
  16. # 管理端服务路由(优先级最高)
  17. - id: admin-route
  18. uri: http://localhost:8088
  19. predicates:
  20. - Path=/admin/**
  21. filters:
  22. - StripPrefix=0
  23. # 管理端API路由(公告等功能)
  24. - id: admin-api-route
  25. uri: http://localhost:8088
  26. predicates:
  27. - Path=/api/admin/**
  28. filters:
  29. - StripPrefix=0
  30. # WebSocket聊天服务路由
  31. - id: websocket-route
  32. uri: http://localhost:1004
  33. predicates:
  34. - Path=/ws/chat/**
  35. filters:
  36. - StripPrefix=0
  37. # 在线状态API路由
  38. - id: online-api-route
  39. uri: http://localhost:1004
  40. predicates:
  41. - Path=/api/online/**
  42. filters:
  43. - StripPrefix=0
  44. # IM服务路由(腾讯云IM相关)
  45. - id: im-api-route
  46. uri: http://localhost:1004
  47. predicates:
  48. - Path=/api/im/**
  49. filters:
  50. - StripPrefix=0
  51. metadata:
  52. response-timeout: 5000
  53. # 好友服务路由(拉黑等功能)
  54. - id: chatfriend-api-route
  55. uri: http://localhost:1004
  56. predicates:
  57. - Path=/api/chatfriend/**
  58. filters:
  59. - StripPrefix=0
  60. # 语音上传服务路由
  61. - id: voice-api-route
  62. uri: http://localhost:1004
  63. predicates:
  64. - Path=/api/voice/**
  65. filters:
  66. - StripPrefix=0
  67. # 聊天REST API路由
  68. - id: chat-api-route
  69. uri: http://localhost:1004
  70. predicates:
  71. - Path=/api/chat/**
  72. filters:
  73. - StripPrefix=0
  74. # 匹配服务路由(必须在 /api/** 之前,避免被覆盖)
  75. - id: match-route
  76. uri: http://127.0.0.1:1003
  77. predicates:
  78. - Path=/match/**
  79. filters:
  80. - StripPrefix=0
  81. # 首页服务路由
  82. # 公告服务路由(HomePage服务)
  83. - id: announcement-route
  84. uri: http://localhost:8081
  85. predicates:
  86. - Path=/api/announcement/**
  87. filters:
  88. - StripPrefix=0
  89. # 动态服务路由(必须在homepage-route之前)
  90. - id: dynamic-route
  91. uri: http://localhost:8086
  92. predicates:
  93. - Path=/api/dynamic/**
  94. filters:
  95. - StripPrefix=0
  96. # 动态媒体文件路由
  97. - id: dynamic-media-route
  98. uri: http://localhost:8086
  99. predicates:
  100. - Path=/media/**
  101. filters:
  102. - StripPrefix=0
  103. # 系统消息(小程序)路由 -> dynamic 服务
  104. - id: system-message-route
  105. uri: http://localhost:8086
  106. predicates:
  107. - Path=/api/message/system/**
  108. filters:
  109. - StripPrefix=0
  110. # 系统消息接口(小程序系统通知)
  111. - id: system-message-all-route
  112. uri: http://localhost:8086
  113. predicates:
  114. - Path=/api/message/**
  115. filters:
  116. - StripPrefix=0
  117. # Essential服务路由(用户信息等基础服务)
  118. - id: essential-route
  119. uri: http://localhost:1005
  120. predicates:
  121. - Path=/api/user/**
  122. filters:
  123. - StripPrefix=0
  124. # Essential服务-反馈路由
  125. - id: essential-feedback-route
  126. uri: http://localhost:1005
  127. predicates:
  128. - Path=/api/feedback/**
  129. filters:
  130. - StripPrefix=0
  131. # Essential服务-择偶要求路由
  132. - id: essential-partner-requirement-route
  133. uri: http://localhost:1005
  134. predicates:
  135. - Path=/api/partner-requirement/**
  136. filters:
  137. - StripPrefix=0
  138. # 积分商城路由(admin服务)
  139. - id: points-mall-route
  140. uri: http://localhost:8088
  141. predicates:
  142. - Path=/api/points/**
  143. filters:
  144. - StripPrefix=1
  145. # 课程服务路由(homePage服务)
  146. - id: course-route
  147. uri: http://localhost:8081
  148. predicates:
  149. - Path=/api/course/**
  150. filters:
  151. - StripPrefix=0
  152. # 课程订单服务路由(Essential服务-微信支付)
  153. - id: course-order-route
  154. uri: http://localhost:1005
  155. predicates:
  156. - Path=/api/course-order/**
  157. filters:
  158. - StripPrefix=0
  159. # 首页服务路由(兜底路由)
  160. - id: homepage-route
  161. uri: http://localhost:8081
  162. predicates:
  163. - Path=/api/**
  164. filters:
  165. - StripPrefix=0
  166. # WebSocket支持配置
  167. websocket:
  168. enabled: true
  169. # 全局CORS配置
  170. globalcors:
  171. corsConfigurations:
  172. '[/**]':
  173. allowedOriginPatterns:
  174. - "*"
  175. # - "https://*.your-domain.com" # 允许所有域名(开发环境)
  176. allowedMethods:
  177. - GET
  178. - POST
  179. - PUT
  180. - DELETE
  181. - OPTIONS
  182. allowedHeaders: "*"
  183. allowCredentials: true
  184. maxAge: 3600
  185. # 日志配置
  186. logging:
  187. level:
  188. org.springframework.cloud.gateway: DEBUG # 开启网关调试日志
  189. com.zhentao: DEBUG # 开启项目调试日志
  190. org.springframework.web: INFO