Back End Development and APIs Projects - Timestamp Microservice

Hi,

I am trying to validate the first project of the “Back End Development and APIs Projects” of freecodecamp, named " Timestamp Microservice".
I have uploaded my code using Replit.
The app is available here : https://microservice1a-1.octdes.repl.co/
The code is (is it available for lecture ?) here : https://replit.com/@octdes/microservice1a-1#index.js

When I copy paste the app link as my solution link on freecodecamp, the correction says everything is incorrect, apart from the first item : “You should provide your own project, not the example URL.”.
From my point of vue, everything is as asked, I don’t understand the problem.

Please, could you tell me what is wrong ?

Thank you very much,

Your browser information:

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

Challenge: Timestamp Microservice

Run the fCC tests with your browser console open, and you’ll see a bunch of errors like

Access to XMLHttpRequest at 'https://microservice1a-1.octdes.repl.co/api' from origin 'https://www.freecodecamp.org' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

which is the classic CORS error. You’ll need to install, use, and configure CORS correctly before the tests actually test your API. One of the practice exercises in the back end section is about CORS I believe, or you can search the forums for plenty of examples.

Hi,
Thank you very much for your answer.
I have google for " Access to XMLHttpRequest at ‘…’ from ‘…’ has been blocked by CORS policy] and the first link on stack overflow has given the answer.
Link : angular - Access to XMLHttpRequest has been blocked by CORS policy - Stack Overflow
For information, I added something like:

 app.use(function (req, res, next) {
    //Enabling CORS
    res.header("Access-Control-Allow-Origin", "*");
    res.header("Access-Control-Allow-Methods", "GET,HEAD,OPTIONS,POST,PUT");
    res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, 
    Accept, x-client-key, x-client-token, x-client-secret, Authorization");
      next();
    });

So thanks again for your answer !

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