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