2
오리온 컨텍스트 브로커 ver에서 도메인 간 아약스 요청을 허용하도록 Access-Control-Allow-Origin을 설정하는 방법. 0.15.0Orion Context Broker에 'Access-Control-Allow-Origin'헤더가 없습니다.
내 JS 스크립트
function capture_sensor_data(){
var contentTypeRequest = $.ajax({
url: 'http://x.x.x.x:1026/ngsi10/queryContext',
data: {
"entities": [
{
"type": "Room",
"isPattern": "false",
"id": "Room1"
}
]
},
type: 'POST',
dataType: 'json',
contentType: 'application/json',
headers: { 'X-Auth-Token' :'you_auth_token'}
});
contentTypeRequest.done(function(data){
console.log(data);
});
contentTypeRequest.fail(function(jqXHR, textStatus){
console.log("DEBUG : Ajax request failed... (" + textStatus + ' - ' + jqXHR.responseText + ").");
});
contentTypeRequest.always(function(jqXHR, textStatus){ });
}; 아마 it has been identified as a potential feature으로 향후 버전에 있다고 할지라도
응답
XMLHttpRequest cannot load http://x.x.x.x:1026/ngsi10/queryContext. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://x.x.x.x' is therefore not allowed access. The response had HTTP status code 405.
오리온이 Access-Control-Allow-Origin 헤더를 지원해야한다고 생각하는 경우 의견에 "+1"을 https://github.com/telefonicaid/fiware-orion/issues/501에 추가하십시오. – fgalan
THX Fermin, 프록시를 만들었 으면 [link] (https://github.com/inter-coder/Orion-Web-Proxy-for-Cross-Domain)에서 찾을 수 있습니다. –