Skip to content

Commit

Permalink
fix empty response body when allowedOrigins is set
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh Eilers committed Apr 29, 2022
1 parent a231ae2 commit 5933dec
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions internal/core/middleware/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,15 @@ func CORS(next http.Handler) http.Handler {
headers = corsContext.AllowedHeaders()
}
if len(domains) > 0 {
domain := domains[0]
for _, d := range domains {
if r.Header.Get("Origin") == d {
browser.SetCORSHeaders(w, d, headers)
return
domain = d
break
}
}
// Not a valid origin, set allowed origin to any allowed origin
browser.SetCORSHeaders(w, domains[0], headers)
browser.SetCORSHeaders(w, domain, headers)
} else {
origin := browser.DefaultAllowedOrigin
if r.Header.Get("Origin") != "" {
Expand Down

0 comments on commit 5933dec

Please sign in to comment.