I find I don’t get that problem with caffeine pills. So that’s what I take while fasting. I also found that light roasted coffee beans give me less heartburn than dark roast. I even prefer light roast taste over dark roast.
I’ve managed not to have coffee until my fast is over by drinking water, green tea, and sparkling water. Drink a huge glass of water as soon as you wake up. Make green tea before and slowly drink it as you start your workday. Have some sparkling water as hunger ramps up. I usually break my fast at noon by walking to my local coffee shop and getting my long-awaited cappuccino!