Ember.js 到POW服务器的Ember CLI代理

Ember.js 到POW服务器的Ember CLI代理,ember.js,proxy,ember-cli,node-http-proxy,rack-pow,Ember.js,Proxy,Ember Cli,Node Http Proxy,Rack Pow,如何让EmberCLI代理到POW服务器?我正在将ember cli master与新的显式代理一起使用。例如,这个例子不起作用: var Proxy = require('http-proxy'); // For options, see: // https://github.com/nodejitsu/node-http-proxy var proxy = Proxy.createProxyServer({}); module.exports = function(app) { a

如何让EmberCLI代理到POW服务器?我正在将ember cli master与新的显式代理一起使用。例如,这个例子不起作用:

var Proxy = require('http-proxy');

// For options, see:
// https://github.com/nodejitsu/node-http-proxy
var proxy = Proxy.createProxyServer({});

module.exports = function(app) {

  app.use('/', function(req, res, next){
    proxy.web(req, res, { target: 'http://api.mywebsite.dev' });
  })

};
但是,如果我将目标更改为localhost,则一切正常:

var Proxy = require('http-proxy');

// For options, see:
// https://github.com/nodejitsu/node-http-proxy
var proxy = Proxy.createProxyServer({});

module.exports = function(app) {

  app.use('/', function(req, res, next){
    proxy.web(req, res, { target: 'http://localhost:9292' });
  })

};

我猜您的服务器没有设置Access Control Allow Origin标头,您应该可以通过查看浏览器开发工具中的请求来判断。我认为这不是问题所在,因为我将API设置为允许来自任何资源上的任何来源的请求,但无论如何我都会检查它。thxI曾经在我的nginx设置中遇到过CORS问题,但我认为我的浏览器调试工具报告了HTTP404错误!我想当我查看我的nginx日志时,我看到了真正的跨源错误,所以请务必查看您的实际web服务器日志,即使您得到的是看似无辜的404。这很可能是由于以下原因:,并用以下方法修复:。Johnny Oshika-谢谢,它成功了!