As laid out in the 12 factor app methodology, environment variables are the best way to handle software configuration. That said, they have to be carefully documented in order to ensure your devops/deployment team know how to set things up.
The best approach I’ve found is to have the software assert all it’s required environment variables upon startup. If any of them are missing, the software throws an informative error and refuses to start. This avoids errors at runtime, potentially much later when the deployment has already been declared green.
Required Env (go) - https://github.com/davidbanham/required_env
Required Env (js) - https://github.com/Prismatik/required_env
Dotenv Safe (go) - https://github.com/prismatik/dotenv_safe