Can't pass FCC "Use the .env File" test case

Tell us what’s happening:
Submitting the link in FCC yields an incorrect solution text: The response of the endpoint /json should change according to the environment variable MESSAGE_STYLE.
Fairly new to glitch and node so I’m not sure what I’m doing wrong. I looked around the forums and tried different variation of the solution but alas nothing is working. SOS.

Your code so far
Link to project: https://glitch.com/~cumbersome-serious-amphibian

var express = require("express");
var app = express();

// --> 7)  Mount the Logger middleware here
/*
app.use((req, res, next) => {
  let string = `${req.method} ${req.path} - ${req.ip}`;
  console.log(string);
  next();
});
*/
// --> 11)  Mount the body-parser middleware  here

/** 1) Meet the node console. */
//console.log("Hello World")

/** 2) A first working Express Server */
/*
app.get("/", (req, res) => {
  res.send("Hello Express");
});
*/

/** 3) Serve an HTML file */
/*
app.get("/", function(req, res) {
  res.sendFile(__dirname + "/views/index.html");
});
*/

/** 4) Serve static assets  */
/*
app.use(express.static(__dirname + "/public"));
*/

/** 5) serve JSON on a specific route */
/*
app.get("/json", (req, res) => {
  res.json({
    message: "Hello json"
  });
});
*/

/** 6) Use the .env file to configure the app */
app.get("/json", (req, res) => {
  if(process.env.MESSAGE_STYLE === "uppercase"){
    return res.json({"message" : "HELLO JSON"});
  }
   return res.json({"message" : "Hello json"});
});
module.exports = app;

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.97 Safari/537.36.

Challenge: Use the .env File

Link to the challenge:

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

Please use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks are not single quotes.

markdown_Forums

Welcome bccruz.

This issue has come up a lot, over the last few hours.

  1. Do you see anything in Glitch’s console?
  2. Check the status of Glitch: status.glitch.com

Hope this helps

Thank you for the reply. I saw your post in another forum. I believe it is some sort of server error on the FCC end. Every time I submit the link on FCC, it break the app on glitch.

" failed to start application on cumbersome-serious-amphibian.glitch.me

This is most likely because your project has a code error.
Check your project logs, fix the error and try again. "

Glitch Console Error code:

_http_outgoing.js:470
1:50 PM
throw new ERR_HTTP_HEADERS_SENT(‘set’);
1:50 PM
^
1:50 PM
1:50 PM
Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
1:50 PM
at ServerResponse.setHeader (_http_outgoing.js:470:11)
1:50 PM
at ServerResponse.header (/rbd/pnpm-volume/eba63627-f26a-44ed-be74-971cc151e5f0/node_modules/express/lib/response.js:771:10)
1:50 PM

at ServerResponse.send (/rbd/pnpm-volume/eba63627-f26a-44ed-be74-971cc151e5f0/node_modules/express/lib/response.js:170:12)
1:50 PM
at ServerResponse.json (/rbd/pnpm-volume/eba63627-f26a-44ed-be74-971cc151e5f0/node_modules/express/lib/response.js:267:15)

1:50 PM

at /rbd/pnpm-volume/eba63627-f26a-44ed-be74-971cc151e5f0/node_modules/fcc-express-bground/index.js:97:15

1:50 PM

at IncomingMessage.r.on (/rbd/pnpm-volume/eba63627-f26a-44ed-be74-971cc151e5f0/node_modules/fcc-express-bground/index.js:29:26)

1:50 PM

at IncomingMessage.emit (events.js:189:13)

1:50 PM

at IncomingMessage.Readable.read (_stream_readable.js:487:10)
1:50 PM
at flow (stream_readable.js:953:34)
1:50 PM
at resume
(_stream_readable.js:934:3)

Thank you, for mentioning this.

We will be looking into it, but nothing has changed on freeCodeCamp’s side that would affect this. So, I suspect it is likely some new compatibility issue.

1 Like