From 1cfd4a48d9f9026a7f58f92ffb9a691773392b5d Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Fri, 31 May 2019 09:23:55 -0700 Subject: [PATCH] Add specific headers in CORS, along with wildcard (#7726) Fixes #7492 --- cmd/generic-handlers.go | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/cmd/generic-handlers.go b/cmd/generic-handlers.go index 6423d6be3..69a9a30d5 100644 --- a/cmd/generic-handlers.go +++ b/cmd/generic-handlers.go @@ -379,6 +379,20 @@ type resourceHandler struct { // setCorsHandler handler for CORS (Cross Origin Resource Sharing) func setCorsHandler(h http.Handler) http.Handler { + commonS3Headers := []string{ + "Date", + "ETag", + "Server", + "Connection", + "Accept-Ranges", + "Content-Range", + "Content-Encoding", + "Content-Length", + "Content-Type", + "X-Amz*", + "x-amz*", + "*", + } c := cors.New(cors.Options{ AllowedOrigins: []string{"*"}, @@ -391,8 +405,8 @@ func setCorsHandler(h http.Handler) http.Handler { http.MethodOptions, http.MethodPatch, }, - AllowedHeaders: []string{"*"}, - ExposedHeaders: []string{"*"}, + AllowedHeaders: commonS3Headers, + ExposedHeaders: commonS3Headers, AllowCredentials: true, })