gateway-route-example.yml 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. # 网关路由配置示例
  2. # 将此配置添加到 Nacos 的 alien-gateway.yml 配置文件中
  3. #
  4. # 若前端调用 /sse/{tableId} 出现 504 Gateway Timeout:
  5. # 原因:SSE 是长连接,网关默认响应超时(约 30s)会主动断开。
  6. # 解决:必须为 SSE 路径单独配一条路由,且 metadata.response-timeout: -1(见下)。
  7. spring:
  8. cloud:
  9. gateway:
  10. routes:
  11. # 【重要】SSE 长连接路由:必须放在 aliendining 通用路由之前,并关闭响应超时
  12. - id: aliendining-sse
  13. uri: http://${route_or_local_ip}:30014
  14. predicates:
  15. - Path=/aliendining/store/order/sse/**
  16. filters:
  17. - StripPrefix=1
  18. metadata:
  19. response-timeout: -1 # -1 表示不超时,避免 SSE 长连接被网关提前断开
  20. # 微信点餐模块通用路由
  21. - id: aliendining
  22. uri: http://${route_or_local_ip}:30014
  23. predicates:
  24. - Path=/aliendining/**
  25. filters:
  26. - StripPrefix=1
  27. # ---------------------------------------------------------------------------
  28. # 网关白名单(免登录)配置
  29. # 在 Nacos 的 alien-gateway 使用的配置中增加 jwt.skip-auth-urls,以下路径不校验 Token。
  30. #
  31. # 示例:根据商铺ID查询店铺信息和首页展示美食价目表 GET /store/info/detail/{storeId}
  32. # - 经网关访问路径为:/aliendining/store/info/detail/{storeId}(以实际网关 Path 前缀为准)
  33. # - 支持前缀匹配:配置项以 ** 结尾表示该路径及其子路径均放行
  34. #
  35. # jwt:
  36. # skip-auth-urls:
  37. # - /aliendining/store/info/detail/** # 店铺详情+首页价目表,无需登录
  38. # - /aliendining/store/info/tables # 精确匹配示例
  39. # - /other/exact/path
  40. # ---------------------------------------------------------------------------