From 5b1a94c73541a8929b4e2ad2d8d4491c99f6f4a0 Mon Sep 17 00:00:00 2001 From: mappu Date: Sun, 8 Oct 2017 17:06:24 +1300 Subject: [PATCH] fix CORS --- Server.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Server.go b/Server.go index 63a1bc5..1cd30ed 100644 --- a/Server.go +++ b/Server.go @@ -86,6 +86,7 @@ const ( func (this *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) { w.Header().Set(`Server`, SERVER_HEADER) + w.Header().Set(`Access-Control-Allow-Origin`, `*`) // Blanket allow CORS if this.opts.MaxUploadBytes > 0 { r.Body = http.MaxBytesReader(w, r.Body, this.opts.MaxUploadBytes) } @@ -108,8 +109,7 @@ func (this *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) { this.handleUpload(w, r) } else if r.Method == "OPTIONS" { - // Blanket allow - w.Header().Set(`Access-Control-Allow-Origin`, `*`) + // Blanket allow (headers already set) w.WriteHeader(200) } else if r.Method == "GET" && r.URL.Path == `/` {