From 317dcbdda41cafbd5a330602b38b9a52fab5ec6f Mon Sep 17 00:00:00 2001 From: Steve Manuel Date: Fri, 13 Jan 2017 15:48:38 -0800 Subject: adding test in CORS middleware in fix for start --- system/api/handlers.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'system/api/handlers.go') diff --git a/system/api/handlers.go b/system/api/handlers.go index 0be98a4..de7fbcb 100644 --- a/system/api/handlers.go +++ b/system/api/handlers.go @@ -254,13 +254,12 @@ func sendPreflight(res http.ResponseWriter) { // CORS wraps a HandleFunc to respond to OPTIONS requests properly func CORS(next http.HandlerFunc) http.HandlerFunc { - if db.ConfigCache("cors_disabled").([]string)[0] == "true" { - return http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + return db.CacheControl(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + if db.ConfigCache("cors_disabled").(bool) == true { res.WriteHeader(http.StatusForbidden) - }) - } + return + } - return db.CacheControl(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { if req.Method == http.MethodOptions { sendPreflight(res) return -- cgit v1.2.3