도메인 간 API 문제를 파악하려고합니다. Ajax를 사용하여 원격 서버에서 데이터를 가져 오는 Sencha Touch 2.3.1로 만든 응용 프로그램이 있습니다. 내가 직면 한 문제는 로컬 서버에 대한 모든 Ajax 요청에 응답에 모든 헤더가 포함되어 있지 않다는 것입니다. 원격 서버에서 모든 것이 잘 작동하고 헤더가 정상입니다.
다음은 각 서버에 대해 송수신 된 헤더를 보여주는 두 가지 인쇄물입니다.
1 - 로컬 호스트에서 전송 및 수신 헤더 ( HTTP : //local.api - 가상 호스트)
수신 된 헤더 :
Connection Keep-Alive
Content-Length 274
Content-Type text/html; charset=iso-8859-1
Date Mon, 07 Jul 2014 10:58:54 GMT
Keep-Alive timeout=5, max=100
Location http://local.api/fa/?ref.agent/lista-clienti&_dc=1404730734262
Server Apache/2.2.17 (Win32) PHP/5.3.3
보낸 헤더 :
Accept text/html,application/xhtml+xml,
application/xml;q=0.9,*/*;q=0.8
Accept-Encoding gzip, deflate
Accept-Language ro-ro,ro;q=0.8,en-us;q=0.6,en-gb;q=0.4,en;q=0.2
Content-Length 33
Content-Type application/x-www-form-urlencoded; charset=UTF-8
Host local.api
Origin http://sencha.local
Referer http://sencha.local/fisa-agenti/index.html
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:30.0) Gecko/20100101
Firefox/30.0
2-원격 서버 ( http://adgarage.ro ) 에서 보내고받은 헤더
수신 된 헤더
Accept-Ranges bytes
Access-Control-Allow-Cred... true
Access-Control-Allow-Orig... *
Age 0
Connection keep-alive
Content-Length 375
Content-Type application/json
Date Mon, 07 Jul 2014 10:58:52 GMT
Server Apache/2.2.22 (Unix) mod_ssl/2.2.22
OpenSSL/0.9.8e-fips-rhel5
Via 1.1 varnish
X-Powered-By PHP/5.3.13
X-Varnish 562862498
보낸 헤더
Accept text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Encoding gzip, deflate
Accept-Language ro-ro,ro;q=0.8,en-us;q=0.6,en-gb;q=0.4,en;q=0.2
Host adgarage.ro
Origin http://sencha.local
Referer http://sencha.local/fisa-agenti/index.html
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:30.0) Gecko/20100101
Firefox/30.0
Access-Controll-Allow
헤더에 유의하십시오 . 수신 된 헤더 컨테이너에서 누락되었습니다.localhost
그리고 여기 내 .htaccess
파일이 있습니다.
Header set Access-Control-Allow-Origin *
Header set Access-Control-Allow-Credentials: true
이 파일은 두 서버에서 동일합니다. 나는 headers_module
로컬 컴퓨터 에서 활동적이다.
내가 알아 차린 또 다른 점은 로컬 301 moved Permanently
에서받은 응답 상태는 원격 서버에서받은 응답 상태가200 Ok
내가 무엇을 놓치고 있습니까?
감사합니다!
문제를 확인했습니다. 이 항목 에서 설명한대로 301 Moved Permanently
상태 때문에 헤더가 전송되지 않았습니다 .
내 로컬 요청이 http://local.api/fa?ref.agent/...
대신 만들어졌습니다 . 첫 번째 링크에서 http://local.api/fa/?ref.agent/...
후행 슬래시가 누락 되었음을 알 수 /fa
있습니다.
이제 모든 것이 괜찮습니다.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다