Dynamic variables issue in netlify.toml

45 views Asked by At

I have different sites for different environments. Staging, UAT and Production.

I’m using netlify.toml for [[redirects]] so it can redirect to the API.

[[redirects]]
  from = "/v1/*"
  to = "${REACT_APP_API_ENDPOINT}/v1/:splat"
  force = true # COMMENT: ensure that we always redirect
  headers = { X-From = "Netlify" }
  signed = "API_SIGNATURE_TOKEN"
  status = 200

The thing is that I cannot have a versioned netlify.toml for every branch because I will have conflicts.

It’s specified in the documentation that env variables don’t work inside netlify.toml [[redirects]]. We can specify contexts and use them inside netlify.toml, but it can only be done with using Netlify CLI (with --context staging, etc). We have automatic deploys. Inside the Netlify UI there is no section to set contexts based on branches or sites.

I don’t want to use Netlify CLI locally, I want to use the process.env or contexts from Netlify UI based on branches or sites to change the variables dynamically inside netlify.toml.

Is this possible?

0

There are 0 answers