Report this

What is the reason for this report?

How can I use environment-specific config files on App Platform?

Posted on June 25, 2025

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.
0

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

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.