API request header parser microservice

Hi everyone! so my api works but doesnt pass the tests… haha

any thoughts?

Hi, @calebjoelsmith
Thanks for sharing your work and information!

Yesterday I’ve tried the first project for APIs and Microservices Projects, and I was struggling to pass the test…

Finally, I found the error message related to CORS in my browser’s console.

So, please confirm your browser’s console when run the test.
If there is a message related to cross origin resource sharing, you might be able to pass after modifying response header.

// This setting is required to run the test code of fCC.
// boilerplate source code 
var cors = require('cors');
app.use(cors({optionSuccessStatus: 200})); 


Maybe you can modify response header options without “cors” module.
Following is an example to allow Access-Control-Allow-Origin against https://www.freecodecamp.org/.

const allowCrossDomain = function(req, res, next) {
  res.header("Access-Control-Allow-Origin", "https://www.freecodecamp.org");
  res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");



I hope it would be any help.