Completely lost with URL shortener project: how to redirect the short url

Hi everyone. I’m on the URL shortener project and although I have already a vague idea on how to validate the urls and randomly generate a short one, how am I supposed to really generate a link that, say, redirects you from to ? I’m completely lost on this, I know there are tons of project feedbacks but I prefer to avoid spoiling me the whole project.

Thanks in advance

Assuming you are using node and express, this should help:

The express docs are very detailed… You’ll need to read them a lot as you learn backend!

Oh, so the idea is having, for example, redirect to Through a redirect?

Yeah, you have to store both urls in a database. When someone visits /short your express router then goes and looks for that in your DB and redirects to the /long that is associated with it.

1 Like

Oh I see now. It makes sense after the mongoDB chapter, thanks a lot!