Kibana XMLHttpRequest cannot load header

Hi Kibana Team,

I am developing a Kibana plugin. I am trying to make a AJAX call from Kibana Visualization to external web service. Below is my code:

 $.ajax({
     type: "GET",
     url: 'http://localhost/elasticservice',
     headers: {'Content-Type':'application/x-www-form-urlencoded'},
     success: function(result) {
          console.log(result);
     },
     error: function() {
          alert("error");
     },
});

On this, I am getting an error in the console:

  XMLHttpRequest cannot load http://localhost/elasticservice. Response for preflight is invalid (redirect)

Any idea for this error?

Hmm, after some research, i found this question which says your problem is likely due to your use of http as opposed to https.

Peace,
Khalah

hi Khalah,

I checked the link and couple of more links. I tried with HTTPS but it does'nt work either.

Here, it talks about the same problem. From this link, I understand that the problem with calling the external service is, that the service needs to accept the preflight mechanism of Kibana.

So, now I am left with a question, of how to communicate using Kibana preflight. And Idea or suggestion on the same?

After you switched to using HTTPS did you get a different error?

Since the browser's communication is with an external service (Cross-Origin), there is an initial OPTIONS request sent to the service. The browser is expecting that the acknowledging response comes from the server. This gives the service control over which domains are allowed to access it and which methods they are allowed to use.