mirror of
https://github.com/cloudflare/cloudflared.git
synced 2025-07-27 01:09:57 +00:00
TUN-3506: OriginService needs to set request host and scheme for websocket requests
This commit is contained in:
@@ -150,8 +150,15 @@ func uptimeHandler(startTime time.Time) http.HandlerFunc {
|
||||
// This handler will echo message
|
||||
func websocketHandler(logger logger.Service, upgrader websocket.Upgrader) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
// This addresses the issue of r.Host includes port but origin header doesn't
|
||||
host, _, err := net.SplitHostPort(r.Host)
|
||||
if err == nil {
|
||||
r.Host = host
|
||||
}
|
||||
|
||||
conn, err := upgrader.Upgrade(w, r, nil)
|
||||
if err != nil {
|
||||
logger.Errorf("failed to upgrade to websocket connection, error: %s", err)
|
||||
return
|
||||
}
|
||||
defer conn.Close()
|
||||
|
Reference in New Issue
Block a user