I've completed the URL Shortner project but it won't pass

Hi all,

Hopefully someone can help me out here.

I’ve completed the URL Shortener Microservice and it appears to pass all tests, but when I submit the Replit link it’s not accepted. I tried deploying the project to Heroku and it crashes whenever I try to use a short url to redirect to another site.

Works fine on localhost and on Replit, however I did write the code in Repl.it and then quickly now moved over to localhost and Heroku when it wasn’t passing, so maybe I did something wrong for deploying it to Heroku. For reference, all I did was clone the github project, install the packages I’m using, copy my replit code, move my API keys for MongoDB to a .env file, move from the gomix branch to master, and push to Heroku. Looks fine, and works (albeit slower) when creating the URLs or failing tests, but it crashes on redirection there.

Links below to verify. Hopefully someone can help me figure this out. Looking forward to the next series of challenges where I’ll learn about QA testing to hopefully see what I’m doing wrong here.

Solution: Replit Site: @nathandonnelly/boilerplate-project-urlshortener (had to remove URL due to forum restrictions)
Live: https://boilerplate-project-urlshortener.nathandonnelly.repl.co/
Heroku: https://hidden-beyond-49886.herokuapp.com/

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:90.0) Gecko/20100101 Firefox/90.0

Challenge: URL Shortener Microservice

I don’t think there is any issue with submitting a Replit link. But when I submit your Replit link, it does not pass the third test. This is the server response when creating a new short url:

  "original_url": "http://google.com",
  "short_url": "/home/runner/boilerplate-project-urlshortener/api/shorturl/dVcT5JX1w7QjbYsYoYYg5"

As the test indicates, it will then try the following link: /api/shorturl/<short_url>. Now if you change <short_url> to the server response, you get: /api/shorturl//home/runner/boilerplate-project-urlshortener/api/shorturl/dVcT5JX1w7QjbYsYoYYg5, which is not correct, but can easily be fixed.

EDIT: Do you mean that you cannot submit this link: https://replit.com/@nathandonnelly/boilerplate-project-urlshortener? You need to submit the live version: https://boilerplate-project-urlshortener.nathandonnelly.repl.co/

Hi Ben,

I originally tried it and had it set up with a string instead of using __dirname to show the live URL. It didn’t make a difference.

As well, I have now just completed the following challenge, the Exercise Tracker, and I’m experiencing the same problem. I will switch the Short URL displayed to the Live URL and run tests again though, but I don’t think that will work.

EDIT: Yep. Just changed it. You can even click on the Short URL in the JSON and get redirected. It’s just not passing the test for some reason.

I’m also having the same problem with the POSTing exercise data user story requirement for the Exercise Tracker project which I’ve built here: https://boilerplate-project-exercisetracker.nathandonnelly.repl.co/

The JSON should only contain the last part of the url. So instead of:

"short_url": "https://boilerplate-project-urlshortener.nathandonnelly.repl.co//api/shorturl/mbiulFRtkoxfJQHyQFdLm"

It should be:

"short_url": "mbiulFRtkoxfJQHyQFdLm"

Ahh, fantastic. I can’t believe I missed that :man_facepalming:t2:

I went into my Exercise Tracker as well and just matched up the formatting to how it was in the example project and got everything to pass.

Thanks for your help Ben!! :slight_smile:

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.