Different variable/api_url for staging branches?

I see with Netlify it’s possible to have every branch become it’s own staging. Currently on our non-Netlify sites we have a separate url/database that staging pulls data from, different than production. Is it possible somehow to set a different variable for staging branches?

Example:
example pulls from api.example
staging--example.com (or any auto test url) pulls from dev.api.example.com

Hi @octoxan,

Sure, you can store the URL in an environment variable, then in your netlify.toml you can set different environment variables for different context (branches). There’s a reference for this in our docs.

1 Like

This is weird. The point of using Environment variables, or at least one of the most common use-cases for them, is to easily change some configuration/values from a deployment without touching the codebase

IMHO there should a way to do it through the UI, the same way a shell has an export command

*Update: BTW, we ended up creating a new project for our -staging environment, which is an acceptable solution AFAICT :wink: