Skip to content

Take control over your live stream video by running it yourself. Streaming + chat out of the box.

do not pass http.ResponseWriter as pointer to EnableCors (#1440)

Tim Cooperb8c9b8e0e8b0
diff --git a/controllers/chat.go b/controllers/chat.go
index 2424966d9b..31f789b0a8 100644
--- a/controllers/chat.go
+++ b/controllers/chat.go
@@ -12,7 +12,7 @@ import (
// ExternalGetChatMessages gets all of the chat messages.
func ExternalGetChatMessages(integration user.ExternalAPIUser, w http.ResponseWriter, r *http.Request) {
- middleware.EnableCors(&w)
+ middleware.EnableCors(w)
GetChatMessages(w, r)
}
diff --git a/controllers/config.go b/controllers/config.go
index 4fe29e7b5d..3179bda56b 100644
--- a/controllers/config.go
+++ b/controllers/config.go
@@ -29,7 +29,7 @@ type webConfigResponse struct {
// GetWebConfig gets the status of the server.
func GetWebConfig(w http.ResponseWriter, r *http.Request) {
- middleware.EnableCors(&w)
+ middleware.EnableCors(w)
w.Header().Set("Content-Type", "application/json")
pageContent := utils.RenderPageContentMarkdown(data.GetExtraPageBodyContent())
@@ -68,7 +68,7 @@ func GetWebConfig(w http.ResponseWriter, r *http.Request) {
// GetAllSocialPlatforms will return a list of all social platform types.
func GetAllSocialPlatforms(w http.ResponseWriter, r *http.Request) {
- middleware.EnableCors(&w)
+ middleware.EnableCors(w)
w.Header().Set("Content-Type", "application/json")
platforms := models.GetAllSocialHandles()
diff --git a/controllers/hls.go b/controllers/hls.go
index 60a22373a4..1cdb4e837a 100644
--- a/controllers/hls.go
+++ b/controllers/hls.go
@@ -45,6 +45,6 @@ func HandleHLSRequest(w http.ResponseWriter, r *http.Request) {
cacheTime := utils.GetCacheDurationSecondsForPath(relativePath)
w.Header().Set("Cache-Control", "public, max-age="+strconv.Itoa(cacheTime))
}
- middleware.EnableCors(&w)
+ middleware.EnableCors(w)
http.ServeFile(w, r, fullPath)
}
diff --git a/controllers/index.go b/controllers/index.go
index 59eee5fed1..7e2f84be30 100644
--- a/controllers/index.go
+++ b/controllers/index.go
@@ -34,7 +34,7 @@ type MetadataPage struct {
// IndexHandler handles the default index route.
func IndexHandler(w http.ResponseWriter, r *http.Request) {
- middleware.EnableCors(&w)
+ middleware.EnableCors(w)
isIndexRequest := r.URL.Path == "/" || filepath.Base(r.URL.Path) == "index.html" || filepath.Base(r.URL.Path) == ""
// For search engine bots and social scrapers return a special
diff --git a/controllers/status.go b/controllers/status.go
index 830cce6937..eb8f23621f 100644
--- a/controllers/status.go
+++ b/controllers/status.go
@@ -11,7 +11,7 @@ import (
// GetStatus gets the status of the server.
func GetStatus(w http.ResponseWriter, r *http.Request) {
- middleware.EnableCors(&w)
+ middleware.EnableCors(w)
status := core.GetStatus()
response := webStatusResponse{
diff --git a/router/middleware/cors.go b/router/middleware/cors.go
index 57c4284c0b..6f486a236b 100644
--- a/router/middleware/cors.go
+++ b/router/middleware/cors.go
@@ -4,7 +4,7 @@ import (
"net/http"
)
-// EnableCors enables the cors header on the responses.
-func EnableCors(w *http.ResponseWriter) {
- (*w).Header().Set("Access-Control-Allow-Origin", "*")
+// EnableCors enables the CORS header on the responses.
+func EnableCors(w http.ResponseWriter) {
+ w.Header().Set("Access-Control-Allow-Origin", "*")
}