修改配置
This commit is contained in:
parent
13db8a2600
commit
2597f02517
|
|
@ -9,6 +9,8 @@ import org.springframework.context.annotation.Configuration;
|
||||||
/**
|
/**
|
||||||
* Gateway 路由配置
|
* Gateway 路由配置
|
||||||
* 配置 WebSocket 转发规则
|
* 配置 WebSocket 转发规则
|
||||||
|
*
|
||||||
|
* 注意:路由配置已移至 application.yml,此 Java 配置已禁用以避免冲突
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Configuration
|
@Configuration
|
||||||
|
|
@ -16,20 +18,21 @@ public class GatewayConfig {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 配置路由规则
|
* 配置路由规则
|
||||||
* 将 /ws/api/** 转发到 ws://iot.t-aaron.com:18080/api/**
|
* 将 /api/ws/** 转发到 ws://iot.t-aaron.com:18080/api/ws/**
|
||||||
|
*
|
||||||
|
* 此配置已注释,使用 application.yml 中的配置
|
||||||
*/
|
*/
|
||||||
@Bean
|
// @Bean
|
||||||
public RouteLocator customRouteLocator(RouteLocatorBuilder builder) {
|
// public RouteLocator customRouteLocator(RouteLocatorBuilder builder) {
|
||||||
return builder.routes()
|
// return builder.routes()
|
||||||
.route("websocket-route", r -> r
|
// .route("websocket-route", r -> r
|
||||||
.path("/ws/api/**")
|
// .path("/api/ws/**")
|
||||||
.filters(f -> f
|
// .filters(f -> f
|
||||||
.stripPrefix(1) // 移除 /ws 前缀
|
// .filter(new com.tuoheng.gateway.filter.WebSocketFilter().apply(
|
||||||
.filter(new com.tuoheng.gateway.filter.WebSocketFilter().apply(
|
// new com.tuoheng.gateway.filter.WebSocketFilter.Config()))
|
||||||
new com.tuoheng.gateway.filter.WebSocketFilter.Config()))
|
// )
|
||||||
)
|
// .uri("ws://iot.t-aaron.com:18080")
|
||||||
.uri("ws://iot.t-aaron.com:18080")
|
// )
|
||||||
)
|
// .build();
|
||||||
.build();
|
// }
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,9 +10,8 @@ spring:
|
||||||
- id: websocket-route
|
- id: websocket-route
|
||||||
uri: ws://iot.t-aaron.com:18080
|
uri: ws://iot.t-aaron.com:18080
|
||||||
predicates:
|
predicates:
|
||||||
- Path=/ws/api/**
|
- Path=/api/ws/**
|
||||||
filters:
|
filters:
|
||||||
- StripPrefix=1
|
|
||||||
- name: WebSocketFilter
|
- name: WebSocketFilter
|
||||||
|
|
||||||
# 启用 JWT 认证(默认为 false,即不启用)
|
# 启用 JWT 认证(默认为 false,即不启用)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue