whenever I try to do some redirecting to another web page (e.g. google.com) with my nodejs express server it will fail returning the following error:
throw er; // Unhandled stream error in pipe.
^
Error: getaddrinfo ENOTFOUND google.com
at errnoException (dns.js:44:10)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:94:26)
I tried many differend solutions I found on SO (e.g. Node.js getaddrinfo ENOTFOUND) already. Not even the ones I found on the node.js (https://nodejs.org/api/http.html#http_http_get_options_callback for example) website won't work. Right now I am trying the most simple version:
var express = require('express');
var app = express();
var request = require('request');
app.get('/', function(req,res) {
var newurl = 'http://google.com/';
request(newurl).pipe(res);
});
app.listen(1337);
or this one
var request = require('request');
request('http://www.google.com', function (error, response, body) {
if (!error && response.statusCode == 200) {
console.log(body) // Show the HTML for the Google homepage.
} else {
console.log(error, response, body);
}
});