HTTP GET亚马逊从jQuery的或XMLHtt prequest AWS失败,产地不受访问控制 - 允许 - 原产地允许 [英] HTTP GET to amazon aws from jquery or XMLHttpRequest fails with Origin is not allowed by Access-Control-Allow-Origin

查看:373
本文介绍了HTTP GET亚马逊从jQuery的或XMLHtt prequest AWS失败,产地不受访问控制 - 允许 - 原产地允许的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一些坏运气得到亚马逊的AWS安全令牌的jQuery或XMLHtt prequest。当我发送一个HTTP GET从jQuery的或XmlHtt prequest,我得到源HTTP:// MY_IP不受访问控制 - 允许 - 原产地允许,但如果我贴了相同的URL在浏览器中,它一切都很好。

Having some bad luck with getting amazon AWS security token from jQuery or XMLHttpRequest. When I send a HTTP GET from jQuery or XmlHttpRequest, I get "Origin http:// MY_IP is not allowed by Access-Control-Allow-Origin.", but if I paste the same URL in my browser, it all goes fine.

我的code:

var url_ = "https://sts.amazonaws.com/?Action=GetSessionToken" +
            "&DurationSeconds=3600" +
            "&AWSAccessKeyId=" + AccessKeyId +
            "&Version=2011-06-15" +
            "&Timestamp=" + encode(timestamp) +
            "&Signature=" + encode(hash) +
            "&SignatureVersion=2&SignatureMethod=HmacSHA256";
$.get(url_, function(data) {
alert("response: "+data);
});

我的头:

响应头
接受-范围字节
年龄198
连接保持
内容长度3739
内容类型text / html
日期星期一,2012年6月25日17点48分20秒GMT
Etag的48c4862-e9b-4c34f76b13400
上次修改星期一,2012年6月25 17点39分28秒GMT
代理服务器的连接保持
服务器的Apache / 2.2.21(Unix的)了mod_ssl / 2.2.21的OpenSSL / 0.9.8r DAV / 2 PHP / 5.3.10用了Suhosin-补丁

Response Headers
Accept-Ranges bytes
Age 198
Connection Keep-Alive
Content-Length 3739
Content-Type text/html
Date Mon, 25 Jun 2012 17:48:20 GMT
Etag "48c4862-e9b-4c34f76b13400"
Last-Modified Mon, 25 Jun 2012 17:39:28 GMT
Proxy-Connection Keep-Alive
Server Apache/2.2.21 (Unix) mod_ssl/2.2.21 OpenSSL/0.9.8r DAV/2 PHP/5.3.10 with Suhosin-Patch

请求头
接受text / html的,是application / xhtml + xml的,应用程序/ XML; Q = 0.9, / 的; Q = 0.8
接受编码gzip压缩,紧缩
接受语言EN-US,EN; Q = 0.5
DNT 1
主机 MY_IP
如果修改 - 周一由于2012年6月25日17时13分16秒GMT
如果 - 无 - 匹配48c127c-ea2-4c34f18fe6300
代理服务器的连接保持
用户代理的Mozilla / 5.0(Macintosh电脑;英特尔的Mac OS X 10.7; RV:12.0)的Gecko / 20100101 Firefox的/ 12.0

Request Headers
Accept text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8
Accept-Encoding gzip, deflate
Accept-Language en-us,en;q=0.5
DNT 1
Host MY_IP
If-Modified-Since Mon, 25 Jun 2012 17:13:16 GMT
If-None-Match "48c127c-ea2-4c34f18fe6300"
Proxy-Connection keep-alive
User-Agent Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:12.0) Gecko/20100101 Firefox/12.0

浏览器的头文件(如果使用的浏览器的URL)

响应头
内容长度808
内容类型为text / xml
日期星期一,2012年6月25日十七时31分54秒GMT
的X AMZN-请求ID a854ff13-BEEB-11e1的-b3ac-0147da731d96

Response Headers
Content-Length 808
Content-Type text/xml
Date Mon, 25 Jun 2012 17:31:54 GMT
x-amzn-RequestId a854ff13-beeb-11e1-b3ac-0147da731d96

请求头
接受text / html的,是application / xhtml + xml的,应用程序/ XML; Q = 0.9, / 的; Q = 0.8
接受编码gzip压缩,紧缩
接受语言EN-US,EN; Q = 0.5
连接保持
DNT 1
主机 sts.amazonaws.com
用户代理的Mozilla / 5.0(Macintosh电脑;英特尔的Mac OS X 10.7; RV:12.0)的Gecko / 20100101 Firefox的/ 12.0

Request Headers
Accept text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8
Accept-Encoding gzip, deflate
Accept-Language en-us,en;q=0.5
Connection keep-alive
DNT 1
Host sts.amazonaws.com
User-Agent Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:12.0) Gecko/20100101 Firefox/12.0

我试着从 http://www.html5rocks.com/en一些code /教程/ CORS / ,但没有运气

任何帮助是pciated AP $ P $

Any help is appreciated

推荐答案

您问这个问题前一段时间,你可能已经发现你的答案,但如果有人在寻找这个问题的答案,在这里是

You asked that question a while ago, you might already have found your answer, but in case someone else is looking for the answer to this question, here it is:

访问控制 - 允许 - 原产地是XMLHtt prequest一项安全功能做一个请求正在运行的JavaScript网页的域之外时。

Access-Control-Allow-Origin is a security feature of XMLHttpRequest when doing a request that is outside of the domain of the web page running the javascript.

例如,网页 http://foo.com/index.html 是做XMLHtt prequest要求 http://bar.com/query?a=b ,服务器在bar.com必须把访问控制 - 允许 - 产地的响应头指定跨域请求允许的。

For example, a web page http://foo.com/index.html is doing a XMLHttpRequest request for http://bar.com/query?a=b, the server at bar.com must put Access-Control-Allow-Origin in the response headers to specify that cross domain requests are permitted.

亚马逊AWS,遗憾的是并没有提供访问控制 - 允许 - 产地的响应头,这样就意味着你不能使用这种技术来访问它。

Amazon AWS, unfortunately, does not provide Access-Control-Allow-Origin in the response headers, so that means that you can't access it using this technique.

这与AWS工作的唯一方法是使用闪光灯代理XMLHtt prequest,但已经安装了闪存的设备上,这仅适用(没有iPhone或ipad公司)。

The only technique that works with AWS is using flash to proxy the XMLHttpRequest, but this only works on devices that have flash installed (no iphone or ipads).

这篇关于HTTP GET亚马逊从jQuery的或XMLHtt prequest AWS失败,产地不受访问控制 - 允许 - 原产地允许的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆