I’m deploying the same app to both staging and production environments using DigitalOcean App Platform.
Is there a recommended way to manage separate environment-specific config files (e.g. config.staging.json vs config.prod.json) or environment-based logic?
Right now I’m hardcoding things based on environment variables, but I wonder if there’s a cleaner pattern others are using.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Accepted Answer
Hi there,
I think that the App Platform doesn’t support auto-loading different config files based on environment names, but the cleanest way is exactly what you’re already doing, control config behavior via environment variables.
For example, set NODE_ENV=production or APP_ENV=staging in the App Platform dashboard per environment. Then load the appropriate config in your code:
const config = require(`./config.${process.env.APP_ENV || 'prod'}.json`);
You can define APP_ENV separately for each deployment (staging vs prod) under Settings -> Environment Variables in App Platform.
This avoids duplicating code or maintaining multiple config branches, and it works well for CI/CD setups too.
For more complex setups, tools like dotenv, config, or env-var packages help manage fallbacks and validations.
- Bobby
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Scale up as you grow — whether you're running one virtual machine or ten thousand.

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.
