2015-01-30 2 views
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. 

답변

1

현재 오리온 버전 (0.18.1)는 응답의 액세스 제어 - 허용 - 원산지 헤더를 포함하지 않습니다.

현재 가능한 해결책 중 하나는 Orion과 클라이언트 사이에 배치 된 프록시를 사용하여 클라이언트에 전달하기 전에 Orion의 응답에 해당 헤더를 추가하는 것입니다.

+1

오리온이 Access-Control-Allow-Origin 헤더를 지원해야한다고 생각하는 경우 의견에 "+1"을 https://github.com/telefonicaid/fiware-orion/issues/501에 추가하십시오. – fgalan

+1

THX Fermin, 프록시를 만들었 으면 [link] (https://github.com/inter-coder/Orion-Web-Proxy-for-Cross-Domain)에서 찾을 수 있습니다. –