URL Shortener Microservice: test time outs

Tell us what’s happening:
I’ve completed the project and it works perfectly fine when I try myself. All the test cases meet the requirements but when I submit the solution, the tests are times out.

Also, the 4th test for invalid_url sometimes gets checked and sometimes does not.

I’ve been working on this for 2 days and it’s really annoying since it works totally fine on my machine.

Your project link(s)

solution: boilerplate-project-urlshortener - Replit

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36 Edg/113.0.1774.57

Challenge: Back End Development and APIs Projects - URL Shortener Microservice

Link to the challenge:

Your URL validation is not correct.

Use the suggested dns method or an npm package for validating URLs.

Or at least inspect the request so you know what a valid/invalid URL looks like if you absolutely have to do your own validation (which I would not recommend).

I’ve corrected it to use dns module. Now the validation part is fine but i’m having problems redirecting to the website.

It’s weird, it works fine when I run it from my VS Code but it crashes when I use replit.

Can you please suggest a fix?

I can only go by the code I can see on Replit.

If you look at the response in the browsers network tab you can see that you are still not doing the URL validation correctly.

dns.lookup takes a hostname (no protocol or paths)

console.log(new URL('https://forum.freecodecamp.org/t/url-shortener-microservice-test-time-outs/612988').hostname)
// forum.freecodecamp.org

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