because the passed req.body.url could contain more than just the hostname after the protocol, such as query parameters, and you need to pass just the hostname portion to the dns lookup. I used URL object to test for both the protocol and hostname.
Also, I don’t think you want to do this
return res.redirect('http://' + data.url);
The original protocol may not be http. I stored the full req.body.url and used this for redirect.