From 1c45e1135895c95b23fb39e7daa8b45c47f04a5c Mon Sep 17 00:00:00 2001 From: Gabe Kangas Date: Sat, 13 Jun 2020 17:08:34 -0700 Subject: [PATCH] Enable CORS on web server --- main.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/main.go b/main.go index c2c0e5b6f..400e9768d 100644 --- a/main.go +++ b/main.go @@ -51,6 +51,7 @@ func startChatServer() { // static files http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + enableCors(&w) http.ServeFile(w, r, path.Join("webroot", r.URL.Path)) if path.Ext(r.URL.Path) == ".m3u8" { @@ -66,6 +67,10 @@ func startChatServer() { log.Fatal(http.ListenAndServe(":"+strconv.Itoa(configuration.WebServerPort), nil)) } +func enableCors(w *http.ResponseWriter) { + (*w).Header().Set("Access-Control-Allow-Origin", "*") +} + func getStatus(w http.ResponseWriter, r *http.Request) { status := Status{ Online: stats.IsStreamConnected(),