application.yml 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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. # 聊天REST API路由
  38. - id: chat-api-route
  39. uri: http://localhost:1004
  40. predicates:
  41. - Path=/api/chat/**
  42. filters:
  43. - StripPrefix=0
  44. # 匹配服务路由(必须在 /api/** 之前,避免被覆盖)
  45. - id: match-route
  46. uri: http://127.0.0.1:1003
  47. predicates:
  48. - Path=/match/**
  49. filters:
  50. - StripPrefix=0
  51. # 首页服务路由
  52. # 公告服务路由(HomePage服务)
  53. - id: announcement-route
  54. uri: http://localhost:8081
  55. predicates:
  56. - Path=/api/announcement/**
  57. filters:
  58. - StripPrefix=0
  59. # 动态服务路由(必须在homepage-route之前)
  60. - id: dynamic-route
  61. uri: http://localhost:8086
  62. predicates:
  63. - Path=/api/dynamic/**
  64. filters:
  65. - StripPrefix=0
  66. # 动态媒体文件路由
  67. - id: dynamic-media-route
  68. uri: http://localhost:8086
  69. predicates:
  70. - Path=/media/**
  71. filters:
  72. - StripPrefix=0
  73. # 系统消息(小程序)路由 -> dynamic 服务
  74. - id: system-message-route
  75. uri: http://localhost:8086
  76. predicates:
  77. - Path=/api/message/system/**
  78. filters:
  79. - StripPrefix=0
  80. # 系统消息接口(小程序系统通知)
  81. - id: system-message-all-route
  82. uri: http://localhost:8086
  83. predicates:
  84. - Path=/api/message/**
  85. filters:
  86. - StripPrefix=0
  87. # Essential服务路由(用户信息等基础服务)
  88. - id: essential-route
  89. uri: http://localhost:1005
  90. predicates:
  91. - Path=/api/user/**
  92. filters:
  93. - StripPrefix=0
  94. # 聊天REST API路由
  95. - id: chat-api-routev
  96. uri: http://localhost:1004
  97. predicates:
  98. - Path=/api/chatfriend/**
  99. filters:
  100. - StripPrefix=0
  101. # 首页服务路由(兜底路由)
  102. - id: homepage-route
  103. uri: http://localhost:8081
  104. predicates:
  105. - Path=/api/**
  106. filters:
  107. - StripPrefix=0
  108. # WebSocket支持配置
  109. websocket:
  110. enabled: true
  111. # 全局CORS配置
  112. globalcors:
  113. corsConfigurations:
  114. '[/**]':
  115. allowedOriginPatterns:
  116. - "*"
  117. # - "https://*.your-domain.com" # 允许所有域名(开发环境)
  118. allowedMethods:
  119. - GET
  120. - POST
  121. - PUT
  122. - DELETE
  123. - OPTIONS
  124. allowedHeaders: "*"
  125. allowCredentials: true
  126. maxAge: 3600
  127. # 日志配置
  128. logging:
  129. level:
  130. org.springframework.cloud.gateway: DEBUG # 开启网关调试日志
  131. com.zhentao: DEBUG # 开启项目调试日志
  132. org.springframework.web: INFO