diff --git a/server/public/handle_shares.go b/server/public/handle_shares.go index 8d256c1ea..812c5d197 100644 --- a/server/public/handle_shares.go +++ b/server/public/handle_shares.go @@ -1,6 +1,7 @@ package public import ( + "bytes" "context" "encoding/json" "errors" @@ -185,11 +186,14 @@ func (pub *Router) handleAPlayer(w http.ResponseWriter, r *http.Request) { } // Render template - w.Header().Set("Content-Type", "text/html; charset=utf-8") - err = tmpl.Execute(w, data) - if err != nil { + var buf bytes.Buffer + if err := tmpl.Execute(&buf, data); err != nil { log.Error(r.Context(), "Error executing aplayer template", err) + http.Error(w, "Error rendering page", http.StatusInternalServerError) + return } + w.Header().Set("Content-Type", "text/html; charset=utf-8") + _, _ = w.Write(buf.Bytes()) }