Can UTI meds cause miscarriage?

October 20th I was having the worst UTI pains, with some spotting. I took my first pregnancy test and it was positive but faint. I went to the doctors and their test was negative. All they told me was I’m not pregnant and I just have a uti and gave me this medicine to take for a week. A couple days later I took another test bc I was feeling pregnant. It was a digital and it was positive. I finished my medicine the doctors gave me and uti was gone. I also made my first OB appointment. On November 14th I was spotting this yellow so I thought it was an infection, I went to the clinic and they confirmed my pregnancy and said the spotting was normal and my urine was clear from infections. On November 16th... 8am, I was spotting and this small clot came out. My boyfriend and I went to the doctors and they confirmed I was going to miscarry. On November 18th the baby had finally passed. It’s been hard and I just can’t help to think what if the medication cause my miscarriage because their test was negative and they thought I wasn’t pregnant? it has always been on the back of my mind and I’m terrified the next time I’m pregnant I’ll have that uti again.