URL Shortener Microservice redirect problem <SOLVED>

Hi campers,

I have been working on for this URL Shortener, all worked well but I notice something weird, everytime I redirect the shortened URL for example : alvinkl-little-url.herokuapp.com/5845
It should redirect to forum.freecodecamp.com but instead, it redirects to alvinkl-little-url.herokuapp.com/forum.freecodecamp.com.

Can anyone help me with this issue??
Thank you so much :slight_smile:

Show us your code - it’ll be easier to help you debug it :slight_smile:

there you go :slight_smile:

The http:// gets stripped somehow. So you redirect to forum.freecodecamp.com instead of http://forum.freecodecamp. Since it misses http, express will think you used a relative url.

EDIT: I guess this is the problem: var url = req.url.replace(/.*:\/\//g, '');

1 Like

wow!! its working!!
Yeah you are right, it misses the http://
Thank you so much man! :smiley:

1 Like