Basic Node and Express - Use the .env File, /_api/use-env-vars 404 (), how do i pass the test?

Tell us what’s happening:
When I run test I get CORS error

Access to XMLHttpRequest at '' from origin '' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
jquery.js:10099 GET net::ERR_FAILED

How can I pass the test?
Is that enough to submit a bug?

Your code so far
Glitch project editor
My glitch project

.env, App.js Solutions


# Environment Config


# store your secrets and config variables in here
# only invited collaborators will be able to see your .env values

# reference these in your code with process.env.SECRET

app.get('/json', (req,res)=>{
    res.json({"message": "HELLO JSON"});
  res.json({"message": "Hello json"});

 app.get( '/json', (req, res)=>{
  let message = 'Hello json';
    res.json({message: message.toUpperCase()});
  } else{
    res.json({message: message});

app.get('/json', (req,res)=>{
  const jsonObj = {"message": "Hello json"}
    res.json({"message": jsonObj.message.toUpperCase()});

app.get('/json', (req,res)=>{
    res.json({message: "HELLO JSON"});
  res.json({message: "Hello json"});

app.get('/json', (req,res)=>res.json(process.env.MESSAGE_STYLE==='uppercase'?{message: "Hello json"}:{"message": "HELLO JSON"});

For pieces of code above I commented out all previous solutions, here I tried to combine 2, just in case they are connected somehow

/** 5) serve JSON on a specific route */

const  json = {"message": "Hello json"};
app.get('/json', (req,res)=>{  

/** 6) Use the .env file to configure the app */
if(process.env.MESSAGE_STYLE==='uppercase') json.message=json.message.toUpperCase();

Your browser information:

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

Challenge: Use the .env File

Link to the challenge:

Hi there,

I’ve not so much time to go deep in your question. I’d suggest you activate cors. Follow this link.

Hey, thanks!

I didn’t think about broader perspective than what’s in the challenge text :woman_facepalming:
I uncommented one of previous challenges, which as far as I understand allows requests from all origins, now I see another error when i run the test

jquery.js:10099 GET 404
and when i open this in browser i see Cannot GET /_api/use-env-vars

Any thoughts/suggestions?

The answer to it all is RTFM :sweat_smile:

For those who prefers experiment and intuitive doing to reading instructions(like me) :woman_facepalming:

What was wrong with the code:

Code parts were mostly correct, but nesting and general placement were a mess.

I was taking each challenge as a stand-alone part, but the file(App.js) is one and those parts should work together.
The final top-level App.js structure would look something like this

//import package
//import package
//import package

//middleware for all requests
//middleware for all requests

	//things todo  for /route0

	//things todo for /route1

//alternative, chainable

export this