Add Access-Control-Allow-Origin: * to all responses

This commit is contained in:
James Mills 2022-03-25 11:27:23 +10:00
parent 152a7664bd
commit 09d2e16ed2
No known key found for this signature in database
GPG Key ID: AC4C014F1440EBD6

View File

@ -476,6 +476,8 @@ func (mb *MessageBus) ServeHTTP(w http.ResponseWriter, r *http.Request) {
}
}()
w.Header().Set("Access-Control-Allow-Origin", "*")
if r.Method == "GET" && (r.URL.Path == "/" || r.URL.Path == "") {
// XXX: guard with a mutex?
out, err := json.Marshal(mb.topics)