Is there a way to inject environment variables, e.g. REACT_APP_MY_API
into the index.html
file?
According to this, it can be done, but I can't seem to get it to work.
.env
REACT_APP_MY_API=https://something.com
index.html
<script type="text/javascript">
console.log("%REACT_APP_MY_API%") // undefined
console.log("%NODE_ENV%") // development
</script>
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…