Hide .env and config.js file in render.com

Hide .env and config.js file in render.com

·

2 min read

Table of Contents:

  • Problem Statement

  • How to ignore .env or config.js file in GitHub

  • .env

  • config.js

  • Hide .env file in render.com

  • Hide config.js file in render.com

Problem Statement

Let's say you want to deploy your backend using render.com and want to keep your .env or config.js file hidden because it contains sensitive information about your database, How would you go about doing that?

How to ignore .env or config.js file in GitHub

To hide the .env or config.js file you can create a .gitignore file and add the file names for the ones you want to hide. If you have pushed your code to GitHub and it still isn't hiding the file you can follow this step instead:

.env

For .env type: git rm .env --cached in the terminal and this will hide the .env when you push it to GitHub.

config.js

For config.js or any other named file you want to hide type: git rm filename

Hide .env file in render.com

Once you have deployed your backend on render.com, select the environment tab and go to environment variables.

Here in Key add the name of your value storing your URI and add the MongoDB URI in the Value text box. Then just press Add Environment Variable and congrats you have securely added your URI to your project 🥳.

Hide config.js file in render.com

To hide a MongoDB URI or sensitive information of any type of database in a config.js file, what you can do is select Environment and go to Secret Files. Type in the name of your file and in Contents add all of the code which is in that file and click Add Secret File. Congrats you have securely added your database information 🥳.