My father also had headache his whole working life on Sundays, not realizing that drinking coffee all week days but not on the weekend, that was probably coffee withdrawal that was giving him a headache by day 2.
[1]: https://journals.lww.com/tcmj/_layouts/15/oaks.journals/down...
"Caffeine — a major component of many varieties of coffee and tea — has been identified as a possible trigger for heartburn in some people. Caffeine may trigger GERD symptoms because it can relax the lower esophageal sphincter (LES)."
I don't get GERD from Mate tea or energy drinks. So I think it's not the caffeine. Since they both contain high amounts of caffeine, even higher than black tea.
I've noticed that if I eat more fiber I can somewhat mitigate this. But it needs to be consistent. Not just a little extra fiber before coffee.
BTW a high-fiber diet can be a natural ozempic by raising GLP-1 levels.