$ git clone https://gist.github.com/kennethkalmer/de832976dedc4ab64798.git proxy
$ cd proxy
$ npm install
$ node proxy.js
profit
{ | |
"name": "proxy", | |
"version": "0.0.0", | |
"description": "Ember-cli interim proxy", | |
"dependencies": { | |
"http-proxy": "^0.10.4" | |
}, | |
"scripts": {}, | |
"repository": { | |
"type": "git", | |
"url": "https://gist.github.com/kennethkalmer/de832976dedc4ab64798.git" | |
}, | |
"author": "IS System Integrators", | |
"license": "MIT" | |
} |
#!/usr/bin/env node | |
var httpProxy = require('http-proxy'); | |
var proxy = httpProxy.createServer(function (req, res, proxy) { | |
var backendHost; | |
if (/^\/(api|auth|uploads|system|users\/auth)/.exec(req.url)) { | |
backendPort = 3000; | |
} else { | |
backendPort = 4200; | |
} | |
proxy.proxyRequest(req, res, { | |
host: "localhost", | |
port: backendPort | |
}); | |
}); | |
port = process.env.PORT || 8000; | |
proxy.listen(port, function() { | |
console.log("Proxying port " + port); | |
}); |
HAWT! 🔥