Skip to content

Instantly share code, notes, and snippets.

@sampaiodiego
Last active May 17, 2018 18:53
Show Gist options
  • Save sampaiodiego/f8e11189aa952c29373d8ebddcf13f6d to your computer and use it in GitHub Desktop.
Save sampaiodiego/f8e11189aa952c29373d8ebddcf13f6d to your computer and use it in GitHub Desktop.
proxy.js
const http = require('http');
const https = require('https');
const proxy = http.createServer().listen(3128);
proxy.on('request', (request, response) => {
console.log('request ->',request.method);
const options = {
hostname: 'www.google.com',
port: 443,
path: request.url,
method: request.method
};
const req = https.request(options, (req) => {
response.writeHead(req.statusCode, req.headers);
return req.pipe(response, {end: true});
});
request.pipe(req, {end: true});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment