Commit 17fd3d44 authored by Andy Wilkinson's avatar Andy Wilkinson

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.
parent 6253cc5d
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment