URL Shortener: tests not passing

Tell us what’s happening:
I’ve been stuck on this project for so long now and I cannot seem to pass any of the tests. It works fine in my eyes and I’ve tried rearranging code and functions but I really do not know at this point and I am afraid of continuing to change the code and get to a place of no return with it and having to scrap it and start from scratch. Please any help will be greatly appreciated.

Your code so far

Live: https://jasso-fcc-urlshortener.herokuapp.com/
Git: GitHub - josejassojr/fcc-urlshortener: A boilerplate for a freeCodeCamp project.

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.81 Safari/537.36

Challenge: URL Shortener Microservice

Link to the challenge:

Ran the tests in chrome and got errors in the browser console like:

Access to fetch at 'https://jasso-fcc-urlshortener.herokuapp.com/api/shorturl' from origin 'https://www.freecodecamp.org' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

It looks like a CORS issue. You have to configure CORS to allow connections (like in the back end practice exercises), not just require the cors module. The code looks reasonable and it looks like you are logging sufficiently to find any other problems.

1 Like

Thank you so much Jeremy!!! It passes! All I did was move the app.use(cors()); to the top and they all passed. Wow, I was stuck on this for so long thank you very much I don’t think I would’ve thought of that.

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