From af82d0542186543491bc948bfced768ebae1d0aa Mon Sep 17 00:00:00 2001 From: Gabe Kangas Date: Mon, 5 Jun 2023 08:51:49 -0700 Subject: [PATCH] fix(api): explicitly disable caching on api responses --- controllers/admin/externalAPIUsers.go | 1 - controllers/controllers.go | 5 ++++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/controllers/admin/externalAPIUsers.go b/controllers/admin/externalAPIUsers.go index b0a281eb6..a6bc1a5d7 100644 --- a/controllers/admin/externalAPIUsers.go +++ b/controllers/admin/externalAPIUsers.go @@ -69,7 +69,6 @@ func GetExternalAPIUsers(w http.ResponseWriter, r *http.Request) { controllers.InternalErrorHandler(w, err) return } - controllers.WriteResponse(w, tokens) } diff --git a/controllers/controllers.go b/controllers/controllers.go index 3a94152bc..e5fb368fb 100644 --- a/controllers/controllers.go +++ b/controllers/controllers.go @@ -5,6 +5,7 @@ import ( "net/http" "github.com/owncast/owncast/models" + "github.com/owncast/owncast/router/middleware" log "github.com/sirupsen/logrus" ) @@ -55,9 +56,11 @@ func WriteSimpleResponse(w http.ResponseWriter, success bool, message string) { } } -// WriteResponse will return an object as a JSON encoded response. +// WriteResponse will return an object as a JSON encoded uncacheable response. func WriteResponse(w http.ResponseWriter, response interface{}) { w.Header().Set("Content-Type", "application/json") + middleware.DisableCache(w) + w.WriteHeader(http.StatusOK) if err := json.NewEncoder(w).Encode(response); err != nil {