Enable CORS on web server

This commit is contained in:
Gabe Kangas 2020-06-13 17:08:34 -07:00
parent afe21c31b6
commit 1c45e11358

View File

@ -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(),