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