我使用Ember和Ember-Model来开发一个前端,它调用一个Spring/Rest/MongoDB后端,它都运行在我的本地机器上,用于开发目的,但是我的调用得到了相同的原始策略错误。
我想知道这件事的共同点是什么。
这是我的代码:
App = Ember.Application.create();
App.Router.map(function(){
});
App.IndexRoute = Ember.Route.extend({
model: function(){
return App.User.find();
}
});
App.User = Ember.Model.extend({
lastName: Ember.attr()
});
App.User.adapter = Ember.Adapter.create({
findAll: function(klass, records) {
$.getJSONP("http://localhost:8080/users").then(function(data) {
records.load(klass, data.users);
});
}
})发布于 2015-02-07 20:19:15
localhost上的相同来源策略与网络的其他部分相同。然而,如果您打开您的web应用程序作为一个文件(即。地址以file:///开头,其他uri,甚至是其他文件的uri,都会有不同的来源。
要解决这个问题,可以从运行在自己机器上的服务器上为应用程序提供服务,而不是通过访问http://localhost来查看它。
https://stackoverflow.com/questions/28386853
复制相似问题