Thank you for your questions. I'm sorry you have suffered with miscarriage in the past. It is understandable that you are worried.
Yes these medicines are safe. They are required to treat certain infections that cause miscarriages and to support the endometrium till the placenta becomes fully functional. Please do discuss your doubts and concerns with your obstetrician as they know your complete history and are best placed to guide you and help overcome doubts or anxiety about your treatment.
with all best wishes for your current pregnancy