Home > Net >  How to write to enviornment variables on heroku
How to write to enviornment variables on heroku

Time:10-13

Don't eat me in the comments
I have made a website ment to me used by only one person
so i want to dynamically write to .env file on heroku without it restting
because this is ment only for one person i dont want to deal with a database
Something like this

require(`dotenv`).config();

console.log(process.env.MYVAL); // Not my val
process.env.MYVAL = "MYVAL"
console.log(process.env.MYVAL); // MYVAL

CodePudding user response:

You can set the environment variables in the settings tab on your heroku dashboard and also using the command line. Please check the following doc to get more info.

https://devcenter.heroku.com/articles/config-vars

Thanks

CodePudding user response:

You need to persist data (even if it is a single value) therefore you should not write to Heroku file system nor storing it in environment variables (Heroku config vars).

I understand using a DB could be not worth it, in this case I would use an external file storage (S3, dropbox, even using Github private repository).

On Files on Heroku you can see some options and (Python) code

  • Related