command = "sed -i \"s/HEADER_PLACEHOLDER/$PROD_API_LOCATION/g\" netlify.toml"
  for = "/*"

The above code should be contained in a netlify.toml file. In the Netlify UI for your site, you can add an environment variable – PROD_API_LOCATION – with the value you desire. This will be read during the build and it'll populate a header called demo. Check out the response headers for this page!