Proxy with express.js

request has been deprecated as of February 2020, I’ll leave the answer below for historical reasons, but please consider moving to an alternative listed in this issue.

Archive

I did something similar but I used request instead:

var request = require('request');
app.get("https://stackoverflow.com/", function(req,res) {
  //modify the url in any way you want
  var newurl="http://google.com/";
  request(newurl).pipe(res);
});

I hope this helps, took me a while to realize that I could do this 🙂

Leave a Comment