Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ember.js/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/neo4j/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ember.js 余烬应用套件CORS_Ember.js_Express_Cors - Fatal编程技术网

Ember.js 余烬应用套件CORS

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

我正在使用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 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})