Skip to content

Instantly share code, notes, and snippets.

@kennethkalmer
Last active August 29, 2015 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kennethkalmer/de832976dedc4ab64798 to your computer and use it in GitHub Desktop.
Save kennethkalmer/de832976dedc4ab64798 to your computer and use it in GitHub Desktop.
Temporary node proxy while ember toolchain fixes the bugs with theirs

Simple proxy

$ 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);
});
@gee-forr
Copy link

HAWT! 🔥

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment