I have a problem deploying my node js app and using .env on render

hi,
my problem is when i want to deploy my node js app, and i connect to my MongoDB account using dotenv file (.env) creating inside it the variable of URI of database), and then calling it in my main app.js file and paste it as a variable process.env.MONGO_URI inside mongoose.connect function, render website gives me an error saying that the first parameter of mongoose.connect method should be a string, and its currently undefined.

however, when i paste the string itself (URI as a string) inside mongoose.connect method, render accepts without issue and deploy my app.

i don’t know what to do, i am sure the variable inside .env file is a string as i have console.log the type and itself and both are strings.

thanks for the help

Hi there,

How are you setting the .env file on Render? Are you using our secrets option: https://docs.render.com/configure-environment-variables#secret-files?

Regards,

Keith
Render Support, UTC+10 :australia: