Issue with .env Variables Not Loading Properly

Hi Glitch Team,

I’m running into a weird issue with one of my Glitch apps. My environment variables from the .env file are not loading into process.env during runtime.

Here’s what I’ve done so far:

  • I’ve double-checked the .env file – no syntax errors and variables are defined like MY_SECRET=value.
  • I’m using dotenv in my project, and it’s required at the top of server.js.
  • Tried restarting the project and even duplicating it, but the issue persists.

Error I’m seeing:

javascript

CopyEdit

undefined is not a function or MY_SECRET is undefined

Has anyone else faced this issue? Could this be a bug on Glitch’s end, or am I missing something obvious?

Thanks in advance!

You’re going to have to either link to the glitch project so folks can see your server.js, or show how you’re using dotenv in your post. Seeing the live site or frontend code cannot show what’s wrong, because that’s not where things are going wrong =)