Skip to content

Instantly share code, notes, and snippets.

@janl

janl/proxy.js Secret

Created January 16, 2014 15:28
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 janl/fc689112b7c71514fd31 to your computer and use it in GitHub Desktop.
Save janl/fc689112b7c71514fd31 to your computer and use it in GitHub Desktop.
exports.proxy = function (config) {
// where to send requests
var target = {
port: config.couch.port,
host: config.couch.host
};
// create a http proxy to CouchDB
http_proxy.setMaxSockets(1024);
var proxy = new http_proxy.HttpProxy({
target: target,
changeOrigin: true,
timeout: 60000
});
return function (url, req, res) {
// rewrite request url
req.url = url;
// proxy request to CouchDB
proxy.proxyRequest(req, res);
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment