Quellcode durchsuchen

Allow websocket connections from any origin

master
Jan Svabenik vor 3 Tagen
Ursprung
Commit
06ce381bb9
1 geänderte Dateien mit 5 neuen und 1 gelöschten Zeilen
  1. +5
    -1
      cmd/sdrd/main.go

+ 5
- 1
cmd/sdrd/main.go Datei anzeigen

@@ -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)


Laden…
Abbrechen
Speichern