We see the following error in the browser console when making a simple ajax request to monitor the health of the Discovery service:
Access to XMLHttpRequest at 'http://host:port/health' from origin 'http://127.0.0.1:8080' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Here is the simple request we're making:
$(document).ready(function(){
var serviceURL = "http://host:port/health";
$.ajax({
type: 'GET',
url: serviceURL,
contentType: 'application/json',
"crossDomain": true,
responseType:'application/json',
success: function(data ) {
console.log(data.status);
},
error: function(error) {
console.log("FAIL");
}
});
});
The SDL documentation states that CORS is disabled: https://docs.sdl.com/LiveContent/content/en-US/SDL%20Tridion%20Sites-v1/GUID-0AED86F8-FDA0-4543-A2A3-D866396D8E51
Does anyone know how to resolve this issue? For example, is there any way to enable CORS for a specific domain/port?