Ad

Best Way To Store Secrets In Application

Which one would be a better way to store secret API keys in Node js applications.

Ad

Answer

Create .env file at root folder and add your all keys, password in that file. To make it secure never ever add file in git repo. Instead add this file in .gitignore file so that git ignore this file when you push your changes.

Syntax of .env file

APP_URL=http://localhost:3000
APP_KEY=SECRETKEY

Additionally to access the keys from your .env file is process.env.APP_KEY

Its secure method, no one can access this file. I use this way. Hope it gives your answer.

Ad
source: stackoverflow.com
Ad