Skip to content

Commit 3a7bc37

Browse files
committed
Update header add location
1 parent d12399d commit 3a7bc37

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

pkg/httpserver/corslayer.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,17 @@ import (
77

88
func (t *HTTPServer) corslayer(handler http.Handler) http.Handler {
99
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
10+
headers := w.Header()
11+
headers.Set("Access-Control-Allow-Origin", "*")
1012
if r.Method != http.MethodOptions {
1113
handler.ServeHTTP(w, r)
1214
return
1315
}
1416

15-
headers := w.Header()
16-
1717
headers.Add("Vary", "Origin")
1818
headers.Add("Vary", "Access-Control-Request-Method")
1919
headers.Add("Vary", "Access-Control-Request-Headers")
2020

21-
headers.Set("Access-Control-Allow-Origin", "*")
22-
2321
reqMethod := r.Header.Get("Access-Control-Request-Method")
2422
if reqMethod != "" {
2523
headers.Set("Access-Control-Allow-Methods", strings.ToUpper(reqMethod))

0 commit comments

Comments
 (0)