mirror of
https://github.com/gogrlx/nats-server.git
synced 2026-04-02 03:38:42 -07:00
Merge branch 'main' into dev
Signed-off-by: Derek Collison <derek@nats.io>
This commit is contained in:
@@ -2342,6 +2342,7 @@ func ResponseHandler(w http.ResponseWriter, r *http.Request, data []byte) {
|
|||||||
} else {
|
} else {
|
||||||
// Otherwise JSON
|
// Otherwise JSON
|
||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
|
w.Header().Set("Access-Control-Allow-Origin", "*")
|
||||||
w.Write(data)
|
w.Write(data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -157,7 +157,14 @@ func readBodyEx(t *testing.T, url string, status int, content string) []byte {
|
|||||||
}
|
}
|
||||||
ct := resp.Header.Get("Content-Type")
|
ct := resp.Header.Get("Content-Type")
|
||||||
if ct != content {
|
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)
|
body, err := io.ReadAll(resp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user