hi, I want to show whether the streaming channels are connected or not on the web page.
So I’m going to call the basic Java api to ajax to use the result.
However, it causes a CORS issue on the web page and cannot get the value.Here is the result window and the way I call up the code below.
function getVideoConnectedList(){
$.ajax({
url: "http://MyIP:8086/connectioncounts?flat",
dataType: "xml",
headers: {
"Authorization" : "Basic " + btoa("ID" + ":" + "PW")
},
success: function(data){
var result = data;
console.log(data);
}
})
}
Access to XMLHttpRequest at 'http://MyIP:8086/connectioncounts?flat' from origin 'http://localhost:8080' has been blocked by CORS policy: Request header field authorization is not allowed by Access-Control-Allow-Headers in preflight response.
The REST API can receive values normally if called in the same way.
If you refer to the link above, as the default setting, CORS heads are using wildcards for Access-Control-Allow-Origin.
Is there any code to add for 8080 port in server.xml, VHost.xml, Application.xml file, etc. to avoid CORS? Or is there anything to modify about the ajax call code?
Thank you.