There are some online pharmacies that are legit where you can buy prescription medication.
But to actually buy the medication on a legit online pharmacy website you need to have a prescription from your doctor for the medicine that you're buying.
Be aware though that there are some online pharmacies that are scams basically and even some that sell illegal medicine that could harm someone.
Only buy prescription medicine from a legit online pharmacy that requires a prescription first for the medicine.