Cant pass exercise with Glitch

Tell us what’s happening:
Hi everyone
I am trying no pass this exercise, but I cant. FCC doesnt want to verifecate my app. Can somebody ask me why? This is my solution
https://rowan-lunar-leopon.glitch.me/
Thanks!

Link to the challenge:

Just as an aside, it is better to post the editor link so we can get to the code easier.

I can see there are a few people looking at it already.

Welcome, whiteadam.

If you go to the console, after submitting the project, you will see CORS errors:

Access to fetch at ‘https://rowan-lunar-leopon.glitch.me/api/exercise/new-user’ 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.

Just allow access from freecodecamp.org

Hope this helps

Hello!

Besides what @Sky020 mentions in the thread, you published your user and password for the mongo database, which you should remove ASAP. Instead, put that information on the .env file.

How do we allow access from FCC?

Hello there,

The easiest way is: https://www.npmjs.com/package/cors

Simple implementation:

const cors = require('cors');
const corsOptions = {
  origin: 'https://freecodecamp.org'
}
app.use(cors(corsOptions));

Hope this helps

Thanks a lot! But this code wont work, however I’ve used another middleware and problem was resolved

app.use((req, res, next)=>{
  res.set("Access-Control-Allow-Origin","*");
  next();
})
1 Like