Skip to content

Instantly share code, notes, and snippets.

@benkutil
Created June 9, 2015 16:55
Show Gist options
  • Save benkutil/5b902defe6be1149fabd to your computer and use it in GitHub Desktop.
Save benkutil/5b902defe6be1149fabd to your computer and use it in GitHub Desktop.
http-proxy
var http = require('http'),
httpProxy = require('http-proxy');
//
// Create your proxy server and set the target in the options.
//
var apiProxy = new httpProxy.createProxyServer({
target: {
host: 'https://api.ppmroadmap.com/v1.2'
}
});
apiProxy.on('proxyReq', function(proxyReq, req, res, options) {
proxyReq.setHeader('Authorization', 'Basic Q0Q4QTVDNTdDRTU5OUQwOTJDNjMyQjBFRDkwODAyNkM4RjYzODYwQ0NCRUYyN0RCMTQ0QjNGMTJGRTJDNEY1MTo=');
});
var apiServer = http.createServer(function (req, res) {
apiProxy.web(req, res);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment