I'm trying to connect to MongoDB in a MERN stack application using .env variables to protect my login information.
The connection URL is expressed in template literals and importing the env variables in place of my information.
This method was working perfectly fine two weeks ago, but when I tried launching the application I keep receiving this error:
Error in GitBash connecting to MongoDB
When I remove the env variables in the connection URL, the connection to MongoDB works without issue. As its never a good idea to just leave unencrypted sensitive login information on an application's file when pushing the data to GitHub, I want to fix this issue but everything I've tried hasn't fixed the issue (again except for simply not using env variables).
This is how I'm structuring my .env file (Without the real sensitive information of course):
I tried installing the dotenv node package and requiring it on the connection.js file but still got the same result
I looked up tutorials on how to properly structure .env files and where to place them within the application (again this method was working a couple of weeks ago when I last worked on the project so I'm not sure what the issue became this time around).