Basic Node and Express (Use the .env File)

In the myApp.js, I cannot get the environment variables defined in my .env hidden file. After adding dotenv module to package.json on my local PC, I managed to get them and the result seems to be correct. But I failed to pass the test when I publish my Node site.

BTW, my public site is https with port 8000.

Any suggestions about this challenge are welcome!

A link to the challenge would help.

“Publish” to where? Many hosting sites like glitch or replit have their own way to handle env variables so dotenv does not work on their platforms. Also if you are pushing from github your .env file should be in your .gitignore so you won’t be pushing your .env file to the hosting site.

Actually I host my Node server on my local PC. Then I use Nginx on a server as a reverse proxy to upstream https requests to my PC. I’ve tested from Intranet and Internet and both passed. So I have no idea why the test always failed on freecodecamp.

What test or challenge is this? What exactly is not passing? What error message are you getting, or test fail message? Without that info it is pretty hard to figure out the issue. Some code might also help.

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