-
-
Save janl/fc689112b7c71514fd31 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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