I have a Node.js app that I want running on a Digital Ocean droplet, however, I have a few environmental variables that I need to be using.
Is it safe for me to create a .env file on it to store the variables? (If no, how do I go about doing this?)
Because I know that services like Heroku have a ‘configuration variable’ setting on their dashboard, whereas Digital Ocean doesn’t
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
Heroku is an app platform, not a VM, which is how they can inject your environment variables.
If it’s on your machine, it’s ok for you to create the file – it won’t be accessible via the web (but it WILL be there).
Here’s how to do it with the Digital Ocean App Platform (https://docs.digitalocean.com/products/app-platform/how-to/use-environment-variables/), and here’s how to do it with just a droplet (https://www.digitalocean.com/community/questions/how-can-i-set-environment-variable-in-droplet-not-using-app)
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0