I am using create react app to bootstrap my app.
I have added two .env files .env.development and .env.production in the root.
.env
.env.development
.env.production
If the .env file works but .env.development or .env.production don't, then create an empty .env file alongside those two. I don't know why but this works for me.