H Jason,
First off, environment variables are only available in very specific contexts:
- at build time,
- to the shell
So, you have to make sure they get interpolated wherever you intend them to be expanded, by your build command. This article talks about that in more depth: [Support Guide] Using environment variables on Netlify correctly
This section of our docs shows a specific example addressing your use case: File-based configuration | Netlify Docs
Let me know how that works for you!