Skip to content

Commit

Permalink
Merge pull request #3906 from butonic/fix-cors-headers
Browse files Browse the repository at this point in the history
fix preflight requests
  • Loading branch information
micbar authored May 22, 2023
2 parents fde10c4 + aa29171 commit cacc3ca
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions changelog/unreleased/fix-preflight-requests.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Bugfix: fix preflight requests

The datagateway now correctly overwrites the preconfigured CORS related headers with the headers returned by a dataprovider.

https://github.com/cs3org/reva/pull/
2 changes: 1 addition & 1 deletion internal/http/interceptors/cors/cors.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func New(m map[string]interface{}) (global.Middleware, int, error) {
}

// TODO(jfd): use log from request context, otherwise fmt will be used to log,
// preventing us from pinging the log to eg jq
// preventing us from piping the log to eg jq
c := cors.New(cors.Options{
AllowCredentials: conf.AllowCredentials,
AllowedHeaders: conf.AllowedHeaders,
Expand Down
2 changes: 1 addition & 1 deletion internal/http/services/datagateway/datagateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ func (s *svc) doPatch(w http.ResponseWriter, r *http.Request) {
func copyHeader(dst, src http.Header) {
for key, values := range src {
for i := range values {
dst.Add(key, values[i])
dst.Set(key, values[i])
}
}
}
2 changes: 1 addition & 1 deletion internal/http/services/owncloud/ocdav/tus.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func (s *svc) handleSpacesTusPost(w http.ResponseWriter, r *http.Request, spaceI

func (s *svc) handleTusPost(ctx context.Context, w http.ResponseWriter, r *http.Request, meta map[string]string, ref *provider.Reference, log zerolog.Logger) {
w.Header().Add(net.HeaderAccessControlAllowHeaders, strings.Join([]string{net.HeaderTusResumable, net.HeaderUploadLength, net.HeaderUploadMetadata, net.HeaderIfMatch}, ", "))
w.Header().Add(net.HeaderAccessControlExposeHeaders, strings.Join([]string{net.HeaderTusResumable, net.HeaderLocation}, ", "))
w.Header().Add(net.HeaderAccessControlExposeHeaders, strings.Join([]string{net.HeaderTusResumable, net.HeaderUploadOffset, net.HeaderLocation}, ", "))
w.Header().Set(net.HeaderTusExtension, "creation,creation-with-upload,checksum,expiration")

w.Header().Set(net.HeaderTusResumable, "1.0.0")
Expand Down

0 comments on commit cacc3ca

Please sign in to comment.