URL Shortener Microservice redirect problem <SOLVED>

URL Shortener Microservice redirect problem <SOLVED>
0

#1

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:


#2

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


#3


there you go :slight_smile:


#4

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, '');


#5

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