I m trying to create a http proxy in node.js which gets the request and makes a new request to the server. My purpose is getting rid of cross origin problem for a while and test my application. But i m getting exception :
_stream_readable.js:536
var ret = dest.write(chunk);
dest.write is not a function
I m totally newbie in the node.js, so am i on the right path ? or is there a better way to do it ?
app.get('/tlq', (req, res) => {
console.log('serve: ' + req.url);
var options = {
hostname: 'www.google.com',
port: 80,
path: req.url,
method: 'GET'
};
var proxy = http.request(options, function (res) {
res.pipe(res, {
end: true
});
});
req.pipe(proxy, {
end: true
});
});