There is a workaround It’s to have a more intelligent build script that selects the appropriate variables to use during build. One can use contexts to choose a different build command, so something like this (untested) is what I might use:
- in the UI, set $STAGING_ENDPOINT and $PRODUCTION_ENDPOINT to different values
- in
netlify.toml
use build commands like this to incorporate them:
[context.staging]
command = "./my-production-build-script.sh"
[context.production]
command = "./my-staging-build-script.sh"
and then have those two scripts use separate environment variables:
in production:
#!/bin/sh
export ACCESS_TOKEN=$PROD_VALUE
<run your build>
and in staging:
#!/bin/sh
export ACCESS_TOKEN=$STAGING_VALUE
<run your build>
Another pattern using a makefile as shown here would work too: Selective Password Protection