Can't set variable for specific context in TOML

Hey, I’ve been trying to change an env var based on the context but I can’t seem to make it work. I need to be able to change the base url I’m using to hit my netlify functions in one of my branch deploys (preProd for me). I’m hitting my functions at ${process.env.REACT_APP_BASE_URL}/.netlify/functions/...,

I’m using a Branch Deploy for my branch called preProd and have specified the following on my TOML file so in order to dynamically get the specific branch deploy base-url instead of the production one when I’m calling my functions:


But it keeps getting overriden by the production context (the env var for which I have specified in the UI). I’m pretty sure there is something simple I am missing here. I’ve also tried specifying the exact name of the branch but to no avail:


Hey @stephanos,

I’m not seeing any netlify.toml file being used for your deploys. Are you sure you’ve that in the repo?

hey @hrishikesh , I used to git.ignore the toml previously but I’ve updated that a while ago to be able to include in my deployments and I can definitely see it in the repo now in both prod and preProd branches that i’m deploying to Netlify. TOML file is under:

  • .netlify
    – netlify.toml
    – state.json

Is the fact that the netlify directory is hidden with “.” affecting this?

Hey @stephanos,

netlify.toml always needs to exist in the root of the project. You can’t keep it anywhere else.

1 Like

Ah right, thanks @hrishikesh moving .toml to the root has fixed this and I can now utilise the branch deploy context for my deployments!:slight_smile:

1 Like