The default rule for a woman who is pregnant or breastfeeding is that she must fast. If however they fear harm for either themselves or their baby they do not need to. In fact, if it is certain that it will cause harm, then it becomes obligatory not to fast.
Abdullah ibn Abbas said explaining the verse; “For those who can do it (with hardship) is a ransom, the feeding of one, that is indigent,” [2:184] he said: This was a concession granted to the aged man and woman who were able to keep fast; they were allowed to leave the fast and instead feed an indigent person for each fast; (and a concession) to pregnant and suckling woman when they apprehended harm (to themselves). [Sunan of Abu Dawood Hadith 2.2311]
A man from Banu Abdullah ibn Ka'b brethren of Banu Qushayr (not Anas ibn Malik, the well-known Companion), said: A contingent from the cavalry of the Messenger of Allah (peace be upon him) raided us. I reached (for he said went) to the Messenger of Allah (peace be upon him) who was taking his meals. He said: Sit down, and take some from this meal of ours. I said: I am fasting, he said: Sit down, I shall tell you about prayer and fasting. Allah has remitted half the prayer to a traveller, and fasting to the traveller, the woman who is suckling an infant and the woman who is pregnant, I swear by Allah, he mentioned both (i.e. suckling and pregnant women) or one of them. I was grieved for not taking the food of the Messenger of Allah (peace be upon him). [Sunan of Abu-Dawood Hadith 2402]
It was narrated that Anas bin Malik said: “The Messenger of Allah (ﷺ) granted a concession to pregnant women who fear for themselves, allowing them not to fast, and to nursing mothers who fear for their infants.” [Sunan Ibm Maajah Hadith 1668] (Da’eef)
There is a slight disagreement on whether they are obliged to pay the ransom, and/or make them up.
In summary, the woman who is pregnant or breastfeeding a child is permitted to leave fasting if she fears harm for herself or the child and should make the day up later.