Back End Development and APIs Projects - URL Shortener Microservice

Hey guys i really want to finish this project but got something weird for me, if i tested this locally i got good redirect and new document as well.

what can i do to solve this?
githubLink: GitHub - Diegocs2410/boilerplate-project-urlshortener: A boilerplate for a freeCodeCamp project.


valid urls start with http or https.

Thank you for your response, now why I’m getting this error message:

It’s like when redirect we are navigating again the backend but with other parameters? other link string?

Can you post a link to your current replit? It would help if you would keep the same replit instead of creating new versions.

Sure Replit

Hey Randell do you got some update here? thks in advanced

I do not understand your app logic. No matter what url a user postsl, you push it into an array named urls and then send back a JSON containing a property named original_url that is the url submitted and another property short_url that ALWAYS will be the value 0. If it is a new url that is not in the urls array, indexOf is always going to return -1 and adding 1 to that is always going to be 0.

The other big issue in your app is if you make a GET request to /api/shorturl/<id> you attempt to find the id in a database. However, it will never find it because you add such a record to the database when the original url is submitted.