Procházet zdrojové kódy

Allow websocket connections from any origin

master
Jan Svabenik před 3 dny
rodič
revize
06ce381bb9
1 změnil soubory, kde provedl 5 přidání a 1 odebrání
  1. +5
    -1
      cmd/sdrd/main.go

+ 5
- 1
cmd/sdrd/main.go Zobrazit soubor

@@ -334,7 +334,11 @@ func main() {

upgrader := websocket.Upgrader{CheckOrigin: func(r *http.Request) bool {
origin := r.Header.Get("Origin")
return origin == "" || strings.HasPrefix(origin, "http://localhost") || strings.HasPrefix(origin, "http://127.0.0.1")
if origin == "" || origin == "null" {
return true
}
// allow same-host or any local IP
return true
}}
http.HandleFunc("/ws", func(w http.ResponseWriter, r *http.Request) {
conn, err := upgrader.Upgrade(w, r, nil)


Načítá se…
Zrušit
Uložit