2012-11-15 1 views
0

내가 분위기 프레임 워크 (https://github.com/Atmosphere/atmosphere)를 사용하여 짓고 있어요 웹 응용 프로그램에 문제가있게 CORS가 있어요CORS - 출처 http : // localhost는 Access-Control-Allow-Origin에 의해 허용되지 않습니다. 오류.

내 요청을 보이는 뭔가 같은 :

/** 
* @constructor 
* @extends {goog.events.EventTarget} 
* 
* @param {string} id The id. 
* @param {string} url The url. 
* @param {Object} request The request options. 
*/ 
atom.Request = function(id, url, request) { 
    this.setParentEventTarget(core.inject(atom)); 
    this.url = url; 
    this.requestOptions_ = {}; 
    goog.object.extend(this.requestOptions_, request); 
    goog.object.extend(this.requestOptions_, { 
    'url' : url, 
    'onError' : goog.bind(this.onError, this), 
    'onClose' : goog.bind(this.onClose, this), 
    'onOpen': goog.bind(this.onOpen, this), 
    'fallbackTransport' : 'jsonp', 
    'onMessage' : goog.bind(this.onMessage, this), 
    'onMessagePublished': goog.bind(this.onMessagePublished, this), 
    'onReconnect': goog.bind(this.onReconnect, this), 
    'enableXDR': 'true', 
    'transport': 'streaming' 
    }); 
    this.id_ = id; 
    this.request_ = $.atmosphere.subscribe(this.requestOptions_); 
}; 
goog.inherits(atom.Request, goog.events.EventTarget); 

서버 (tomcat7.0.32) 내 필터는 transactioncompany의 고르 필터 (http://software.dzhuvinov.com/cors-filter.html)입니다

의 web.xml :

<filter> 
    <filter-name>corsFilter</filter-name> 
    <filter-class>com.thetransactioncompany.cors.CORSFilter</filter-class> 

     <init-param> 
      <param-name>cors.allowGenericHttpRequests</param-name> 
      <param-value>true</param-value> 
     </init-param> 
     <init-param> 
      <param-name>cors.allowOrigin</param-name> 
      <param-value>*</param-value> 
     </init-param> 
     <init-param> 
      <param-name>cors.supportedMethods</param-name> 
      <param-value>GET, HEAD, POST, OPTIONS</param-value> 
     </init-param> 
     <init-param> 
      <param-name>cors.supportedHeaders</param-name> 
      <param-value>Origin, Content-Type, X-Requested-With, Access-Control-Allow-Origin</param-value> 
     </init-param> 
     <init-param> 
      <param-name>cors.supportsCredentials</param-name> 
      <param-value>true</param-value> 
     </init-param> 
     <init-param> 
      <param-name>cors.maxAge</param-name> 
      <param-value>3600</param-value> 
     </init-param> 
</filter> 

클라이언트로부터 요청을하면 Origin http://localhost is not allowed by Access-Control-Allow-Origin. 오류가 발생합니다.

요청 정보 :이 문제에 관해서 내가 생각에서 정말이야이 시점에서

Request Headers 

Cache-Control:no-cache 
Origin:http://localhost 
Pragma:no-cache 
Referer:http://localhost/sportsdesk/build/development/en/application.html 
User-Agent:Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.79 Safari/537.1 

Query String Parameters 

X-Atmosphere-tracking-id:0 
X-Atmosphere-Framework:1.1 
X-Atmosphere-Transport:streaming 
X-Cache-Date:0 
_:1352918719739 

. 누군가 그것을 발견 할 수 있습니까?

건배, 마이크.

+0

응답 헤더 추적을 제공 할 수 있습니까? 또한 테스트와 마찬가지로 cors.supportsCredentials를 "false"로 설정해보십시오. – monsur

+0

Whoa ... 나는 그것을 완료했다고 생각한다! 조금만 조사하게 하죠. – MikePatel

+0

알았어요. 대답하고 받아 들일 것입니다. – MikePatel

답변

1

cors.supportsCredentials를 "false"로 설정하십시오 (XHR 요청시 Credentials를 설정하면 언제든지 다시 활성화 할 수 있습니다).

+0

안녕하세요, Monsur, 비슷한 문제가 있습니다. "Credentials 플래그는 true이지만 Access-Control-Allow-Credentials는"true "가 아닙니다." cors.supportsCredentials를 false로 설정하고 withCredentials를 true로 설정하여 요청을 보냅니다. 도울 수 있니? –

관련 문제