Fixed CORS for WS

incorrect_closing_investigation
Evgeny Kovalev 2 years ago
parent d42b596bf0
commit 66f2cf6cc2
  1. 6
      internal/server/server.go

@ -27,6 +27,9 @@ func wsEndpoint(w http.ResponseWriter, r *http.Request) {
var upgrader = websocket.Upgrader{
ReadBufferSize: 1024,
WriteBufferSize: 1024,
CheckOrigin: func(r *http.Request) bool {
return true // DANGEROUS. USING FOR DEV PURPOSES ONLY
},
}
conn, err := upgrader.Upgrade(w, r, nil)
@ -36,6 +39,8 @@ func wsEndpoint(w http.ResponseWriter, r *http.Request) {
return
}
log.Println(r.RemoteAddr)
for {
messageType, p, err := conn.ReadMessage()
if err != nil {
@ -48,7 +53,6 @@ func wsEndpoint(w http.ResponseWriter, r *http.Request) {
}
}
fmt.Fprintf(w, "hello")
}
func setupRoutes() {

Loading…
Cancel
Save