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.
This commit is contained in:
Andy Wilkinson 2015-02-19 14:30:23 +00:00
parent 6253cc5dc7
commit 17fd3d44b7
1 changed files with 4 additions and 2 deletions

View File

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