From 62fac57c6fb0f0f48b5e3b2bb398fa00b381c287 Mon Sep 17 00:00:00 2001 From: 0ceanSlim Date: Thu, 1 Aug 2024 10:43:17 -0400 Subject: [PATCH] skip origin check --- main.go | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/main.go b/main.go index 254dbe9..2566d82 100644 --- a/main.go +++ b/main.go @@ -70,15 +70,20 @@ func startServer(config *configTypes.ServerConfig, mux *http.ServeMux) { fmt.Println("Error starting server:", err) } } +var wsServer = &websocket.Server{ + Handshake: func(config *websocket.Config, r *http.Request) error { + // Skip origin check + return nil + }, + Handler: websocket.Handler(relay.WebSocketHandler), +} func ListenAndServe(w http.ResponseWriter, r *http.Request) { - if r.Header.Get("Upgrade") == "websocket" { - websocket.Handler(func(ws *websocket.Conn) { - relay.WebSocketHandler(ws) - }).ServeHTTP(w, r) - } else if r.Header.Get("Accept") == "application/nostr+json" { - nip.RelayInfoHandler(w, r) - } else { - app.RootHandler(w, r) - } -} + if r.Header.Get("Upgrade") == "websocket" { + wsServer.ServeHTTP(w, r) + } else if r.Header.Get("Accept") == "application/nostr+json" { + nip.RelayInfoHandler(w, r) + } else { + app.RootHandler(w, r) + } +} \ No newline at end of file