Tell us what’s happening:
This is working on glitch as well as on my localhost but I don’t know why the 2nd and 3rd test cases are failing.
Any help, please.
Thanks.
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.