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