skip origin check

This commit is contained in:
0ceanSlim 2024-08-01 10:43:17 -04:00
parent 27efacc2e4
commit 62fac57c6f

25
main.go
View File

@ -70,15 +70,20 @@ func startServer(config *configTypes.ServerConfig, mux *http.ServeMux) {
fmt.Println("Error starting server:", err) 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) { func ListenAndServe(w http.ResponseWriter, r *http.Request) {
if r.Header.Get("Upgrade") == "websocket" { if r.Header.Get("Upgrade") == "websocket" {
websocket.Handler(func(ws *websocket.Conn) { wsServer.ServeHTTP(w, r)
relay.WebSocketHandler(ws) } else if r.Header.Get("Accept") == "application/nostr+json" {
}).ServeHTTP(w, r) nip.RelayInfoHandler(w, r)
} else if r.Header.Get("Accept") == "application/nostr+json" { } else {
nip.RelayInfoHandler(w, r) app.RootHandler(w, r)
} else { }
app.RootHandler(w, r) }
}
}