mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08:00
Only set CORS headers if they aren't set already
This allow for middleware to set these to more specific values if desired
This commit is contained in:
parent
f25b8c240d
commit
106542a1fe
|
@ -34,15 +34,19 @@ func SetCORS(w http.ResponseWriter, o *regexp.Regexp, r *http.Request) {
|
|||
}
|
||||
|
||||
for k, v := range corsHeaders {
|
||||
w.Header().Set(k, v)
|
||||
if _, ok := w.Header()[k]; !ok {
|
||||
w.Header().Set(k, v)
|
||||
}
|
||||
}
|
||||
|
||||
if o.String() == "^(?:.*)$" {
|
||||
w.Header().Set("Access-Control-Allow-Origin", "*")
|
||||
return
|
||||
}
|
||||
if _, ok := w.Header()["Access-Control-Allow-Origin"]; !ok {
|
||||
if o.String() == "^(?:.*)$" {
|
||||
w.Header().Set("Access-Control-Allow-Origin", "*")
|
||||
return
|
||||
}
|
||||
|
||||
if o.MatchString(origin) {
|
||||
w.Header().Set("Access-Control-Allow-Origin", origin)
|
||||
if o.MatchString(origin) {
|
||||
w.Header().Set("Access-Control-Allow-Origin", origin)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue