From e5836fc98dd7e5cada52ca23339bd3d5fcb38eaf Mon Sep 17 00:00:00 2001 From: Pierre Mdawar Date: Wed, 23 Aug 2023 16:47:30 +0300 Subject: [PATCH 1/2] Added CORS support for the monitoring server --- server/monitor.go | 1 + server/monitor_test.go | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/server/monitor.go b/server/monitor.go index b7b26b48..1fddcd84 100644 --- a/server/monitor.go +++ b/server/monitor.go @@ -2313,6 +2313,7 @@ func ResponseHandler(w http.ResponseWriter, r *http.Request, data []byte) { } else { // Otherwise JSON w.Header().Set("Content-Type", "application/json") + w.Header().Set("Access-Control-Allow-Origin", "*") w.Write(data) } } diff --git a/server/monitor_test.go b/server/monitor_test.go index c98429cb..521df043 100644 --- a/server/monitor_test.go +++ b/server/monitor_test.go @@ -157,7 +157,14 @@ func readBodyEx(t *testing.T, url string, status int, content string) []byte { } ct := resp.Header.Get("Content-Type") if ct != content { - stackFatalf(t, "Expected %s content-type, got %s\n", content, ct) + stackFatalf(t, "Expected %q content-type, got %q\n", content, ct) + } + // Check the CORS header for "application/json" requests only. + if ct == appJSONContent { + acao := resp.Header.Get("Access-Control-Allow-Origin") + if acao != "*" { + stackFatalf(t, "Expected with %q Content-Type an Access-Control-Allow-Origin header with value %q, got %q\n", appJSONContent, "*", acao) + } } body, err := io.ReadAll(resp.Body) if err != nil { From 0d135d416134f116296f6bf06e65009339d1437d Mon Sep 17 00:00:00 2001 From: Derek Collison Date: Fri, 25 Aug 2023 11:04:37 -0700 Subject: [PATCH 2/2] Bump to 2.9.22-RC.1 Signed-off-by: Derek Collison --- server/const.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/const.go b/server/const.go index a489fff9..4eb975d9 100644 --- a/server/const.go +++ b/server/const.go @@ -41,7 +41,7 @@ var ( const ( // VERSION is the current version for the server. - VERSION = "2.9.22-beta.1" + VERSION = "2.9.22-RC.1" // PROTO is the currently supported protocol. // 0 was the original