Taking ranitidine will get rid of the heart burn. It's not harmful to baby at all
I also had really bad heartburn starting just after 30 weeks. I'm 40+6 weeks now and don't have it as bad anymore.
You can take tums to help it. If you don't want to take tums, it sounds strange, but try eating a marshmallow. I don't know why, but for some reason that helped me.