1

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?

  • Why do you want to access the health check endpoint from a browser using a CORS request? These health check endpoints are intended for load balancers. – Rick Pannekoek May 6 at 17:41
  • We're creating a page to monitor the health of all our microservices – Jonathan Primmer May 22 at 6:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.