avoid double CORS headers in federation (#11334)

CORS proxying adds double headers one
by the receiving server, one by proxied
server. Remove them before proxying
when 'Origin' header is found.
master
Harshavardhana 4 years ago committed by GitHub
parent 7575c24037
commit 6a95f412c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      cmd/common-main.go
  2. 10
      cmd/generic-handlers.go

@ -17,6 +17,7 @@
package cmd
import (
"context"
"crypto/x509"
"encoding/gob"
"errors"
@ -61,7 +62,9 @@ func init() {
PassHost: true,
RoundTripper: newGatewayHTTPTransport(1 * time.Hour),
Logger: func(err error) {
logger.LogIf(GlobalContext, err)
if err != nil && !errors.Is(err, context.Canceled) {
logger.LogIf(GlobalContext, err)
}
},
})

@ -580,6 +580,11 @@ func setBucketForwardingHandler(h http.Handler) http.Handler {
r.URL.Scheme = "https"
}
r.URL.Host = getHostFromSrv(sr)
// Make sure we remove any existing headers before
// proxying the request to another node.
for k := range w.Header() {
w.Header().Del(k)
}
globalForwarder.ServeHTTP(w, r)
return
}
@ -630,6 +635,11 @@ func setBucketForwardingHandler(h http.Handler) http.Handler {
r.URL.Scheme = "https"
}
r.URL.Host = getHostFromSrv(sr)
// Make sure we remove any existing headers before
// proxying the request to another node.
for k := range w.Header() {
w.Header().Del(k)
}
globalForwarder.ServeHTTP(w, r)
return
}

Loading…
Cancel
Save