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!
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.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.