Of course, that type of variable namespace will only work in case you are actually building a react app; I suppose you are
If so, it seems likely that your build pipeline somehow ignores your env vars in subprocesses, since that should be set both during build, and after deploy. I wrote an explanation of why this could happen, how to troubleshoot and fix; check out this article but especially the third paragraph for advice that is likely relevant to you: