Ember.js 余烬应用套件CORS
我正在使用Ember App Kit尝试构建一个登录到现有服务器的应用程序。 我的问题是,我得到了以下信息:Ember.js 余烬应用套件CORS,ember.js,express,cors,Ember.js,Express,Cors,我正在使用Ember App Kit尝试构建一个登录到现有服务器的应用程序。 我的问题是,我得到了以下信息: XMLHttpRequest cannot load https://example.server.com/. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8000' is therefore not allowed acces
XMLHttpRequest cannot load https://example.server.com/. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8000' is therefore not allowed access.
我用谷歌搜索了一下,似乎需要在我的express服务器中添加/启用CORS。
我尝试了以下各种示例,例如:
但我无法让它运行
简言之,我试图找到一个示例,说明如何将CORS添加到express服务器上
干杯
Dror将其粘贴在Em.Application.extend中的就绪挂钩中
$(document).ajaxSend(function (event, xhr, settings) {
settings.xhrFields = {
withCredentials: true
};
});
对于express,请尝试在npm上使用cors模块。这一切都应该是开箱即用的。最终,我通过使用一个已经运行的服务器来为我的ember项目提供服务,从而躲过了一劫
感谢kiwiupover和ulisesrmzroche的及时回复您是否允许jQuery进行跨域ajax调用<代码>$.ajaxSetup({crossDomain:true})代码>