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.
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:
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.
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.