我将JSON对象存储在Amazon S3中,希望能够直接使用JavaScript从S3中加载数据。我的GET请求看起来非常通用:
$.ajax({
'type':'GET',
'url':'http://s3.amazonaws.com/mybucketname/'+id,
'dataType':'text',
'success':function(msg) {
alert(msg);
}
});
我收到了以下错误:
XMLHttpRequest cannot load http://s3.amazonaws.com/whatever/whatever. Origin http://mylocalhostname:9000 is not allowed by Access-Control-Allow-Origin.
我可以使用curl从S3获取那个URL,或者直接在浏览器中访问该URL。难道我真的需要通过我的服务器代理所有这些请求吗?