Connect to the database in a Heroku node.js app without revealing authentication details on git -


i have node.js app pushed heroku. uses mongodb it's storage. heroku offers free mongodb addon app can connect to. question is, since connection string of format: mongodb://dbuser:dbpass@host:port/dbname, , since heroku uses git push, how push code public github repo without revealing username , password everyone?

is there no way make database open connections coming heroku app?

i have admit i'm pretty confused on whole matter.

you want read on configuration , config vars in heroku dev center. heroku expects , encourages use config variables (configured on heroku app , not in codebase) protected sensitive data passwords. use heroku config:set variable=value, note heroku addons, when provisioned, automatically add authentication information config variables. can check out has been set heroku config command.

using node, access environment variables process.env.variable, variable name of environment/config variable you're trying access.

as final note, can add local environment variables .env in project directory (add file .gitignore!)... foreman load these when use foreman start or foreman run.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -