bugfix: #173 Websocket fixes 1) The upgrader was refusing reverse proxies, 2) The upgrader was "listening" on /, not /websocket (#177)

This commit is contained in:
James Read
2023-10-24 04:48:16 +00:00
committed by GitHub
parent 311f9a1d00
commit 3db8ae53b5
2 changed files with 27 additions and 8 deletions
+7 -7
View File
@@ -15,7 +15,6 @@ import (
"net/http"
"net/http/httputil"
"net/url"
"strings"
)
// StartSingleHTTPFrontend will create a reverse proxy that proxies the API
@@ -38,13 +37,14 @@ func StartSingleHTTPFrontend(cfg *config.Config) {
apiProxy.ServeHTTP(w, r)
})
mux.HandleFunc("/websocket", func(w http.ResponseWriter, r *http.Request) {
log.Debugf("websocket req: %q", r.URL)
websocket.HandleWebsocket(w, r)
})
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
if strings.Contains(r.Header.Get("Connection"), "Upgrade") {
websocket.HandleWebsocket(w, r)
} else {
log.Debugf("ui req: %q", r.URL)
webuiProxy.ServeHTTP(w, r)
}
log.Debugf("ui req: %q", r.URL)
webuiProxy.ServeHTTP(w, r)
})
srv := &http.Server{