mirror of
https://github.com/0ceanSlim/grain.git
synced 2024-10-29 17:16:31 +00:00
skip origin check
This commit is contained in:
parent
27efacc2e4
commit
62fac57c6f
25
main.go
25
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)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user