From 06ce7bd75ada1fc637a7a2515e085c2f9576ef10 Mon Sep 17 00:00:00 2001 From: Piotr Zduniak Date: Mon, 12 Jan 2015 22:18:34 +0100 Subject: [PATCH] SockJS CORS fix --- setup/setup.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/setup/setup.go b/setup/setup.go index e0afc03..31486d1 100644 --- a/setup/setup.go +++ b/setup/setup.go @@ -280,6 +280,12 @@ func PrepareMux(flags *env.Flags) *web.Mux { // - AutomaticOptions automatically responds to OPTIONS requests mux.Use(func(c *web.C, h http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + // sockjs doesn't want to work with our code, as the author doesn't understand http.Headers + if strings.HasPrefix(r.RequestURI, "/ws") { + h.ServeHTTP(w, r) + return + } + // because why not w.Header().Set("Access-Control-Allow-Credentials", "true")