From 39ddb78c75fff1dc3167dbe8de83e82f02b57962 Mon Sep 17 00:00:00 2001 From: kannappanr <30541348+kannappanr@users.noreply.github.com> Date: Wed, 6 Mar 2019 11:58:53 -0800 Subject: [PATCH] CORS: Expose all headers on response (#7331) Fixes #7289 --- cmd/generic-handlers.go | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/cmd/generic-handlers.go b/cmd/generic-handlers.go index fb73bdae9..28e61e447 100644 --- a/cmd/generic-handlers.go +++ b/cmd/generic-handlers.go @@ -383,7 +383,23 @@ type resourceHandler struct { // setCorsHandler handler for CORS (Cross Origin Resource Sharing) func setCorsHandler(h http.Handler) http.Handler { - c := cors.AllowAll() + + c := cors.New(cors.Options{ + AllowedOrigins: []string{"*"}, + AllowedMethods: []string{ + http.MethodGet, + http.MethodPut, + http.MethodHead, + http.MethodPost, + http.MethodDelete, + http.MethodOptions, + http.MethodPatch, + }, + AllowedHeaders: []string{"*"}, + ExposedHeaders: []string{"*"}, + AllowCredentials: true, + }) + return c.Handler(h) }