Completely stumped by this. I am doing all of the API Microservice Projects as one project.
The app has no issue passing tests for the Exercise Tracker, Request Header Parser and the Timestamp Microservice but for some reason the Url Shortener tests fail due to a CORS Policy error when submitting despite manual tests of the app showing that the app ultimately functions perfectly.
The error thrown is the following and there are also extra error messages which I will also show but my suspicion is that these are just a result of this CORS error:
Access to fetch at ‘https://aidan-sabin-portfolio.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.
Failed to load resource: net::ERR_FAILED (shows it is the /api/shorturl path for my app)
frame-runner.js:98 TypeError: Failed to fetch
_callee$ @ frame-runner.js:98
If you attempt to submit on the URL Shortener project page on FCC it crashes the whole app so testing it yourself will only work for the first person (if you try to see the errors for yourself) but I will restart the dynos in the hope the first person manages to solve it for me
Might be worth mentioning I also tried to add origin: ‘https://freecodecamp.org’ to app.use(cors) but this did not help.
I have set it now so that the hostname would just be in the format freecodecamp.org (have removed the “www.” from the front. This hasn’t solved the issue so maybe I’m unsure what ‘hostname’ really means or it isn’t this part that is breaking the app. Honestly tried about 1000 different solutions at this point and nothing seems to work.