Browse Source

Allow websocket connections from any origin

master
Jan Svabenik 3 days ago
parent
commit
06ce381bb9
1 changed files with 5 additions and 1 deletions
  1. +5
    -1
      cmd/sdrd/main.go

+ 5
- 1
cmd/sdrd/main.go View File

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


Loading…
Cancel
Save