0

How can I get EmberCLI to proxy to a POW server? I'm using ember-cli master with the new explicit proxies (https://github.com/stefanpenner/ember-cli/pull/1530). This for example doesn't work:

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' });
  })

};

However, if I change my target to localhost, everything works fine:

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' });
  })

};
Steve H.
  • 6,912
  • 2
  • 30
  • 49
Matt Beedle
  • 171
  • 1
  • 9
  • 1
    My guess is your server isn't setting the Access-Control-Allow-Origin header (https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS) and you should be able to tell so by looking at the requests from your brower's developer tools. – Leeft Aug 08 '14 at 14:26
  • I don't think this is the issue as I set my API to allow requests from any origin on any resource, but I will check it out anyway. thx – Matt Beedle Aug 08 '14 at 15:30
  • 1
    I once experienced CORS issues with my nginx setup, but I think my browser debug tool reported HTTP 404 errors! I think when I looked at my nginx log, I saw the true cross origin error, so be sure to look at your actual web server logs, even if you're getting a seemingly innocent 404. – Josh Padnick Aug 08 '14 at 22:06
  • This is most likely due to this: https://github.com/nodejitsu/node-http-proxy/issues/696, and fixed with this: https://github.com/nodejitsu/node-http-proxy/pull/723. – Johnny Oshika Nov 09 '14 at 06:54
  • Johnny Oshika - Thanks, it worked! – Roman Jun 09 '15 at 09:15

0 Answers0