Add workaround for Undertow WebSocket client sending illegal Origin

Undertow’s WebSocket client sends an illegal Origin header – it does
not include the scheme, e.g. it’ll send “localhost” rather than
“http://localhost”. This commit works around the problem by allowing
access to the SockJS endpoints from any origin, thereby disabling
OriginHandlerInterceptor’s checking of the Origin header.
pull/2524/head
Andy Wilkinson 10 years ago
parent 6253cc5dc7
commit 17fd3d44b7

@ -45,8 +45,10 @@ public class SampleUndertowWebSocketsApplication extends SpringBootServletInitia
@Override @Override
public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) { public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
registry.addHandler(echoWebSocketHandler(), "/echo").withSockJS(); registry.addHandler(echoWebSocketHandler(), "/echo").setAllowedOrigins("*")
registry.addHandler(snakeWebSocketHandler(), "/snake").withSockJS(); .withSockJS();
registry.addHandler(snakeWebSocketHandler(), "/snake").setAllowedOrigins("*")
.withSockJS();
} }
@Override @Override

Loading…
Cancel
Save