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

Loading…
Cancel
Save