浏览代码

Allow websocket connections from any origin

master
Jan Svabenik 4 天前
父节点
当前提交
06ce381bb9
共有 1 个文件被更改,包括 5 次插入1 次删除
  1. +5
    -1
      cmd/sdrd/main.go

+ 5
- 1
cmd/sdrd/main.go 查看文件

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


正在加载...
取消
保存