The Messenger of Allah ﷺ used to perform voluntary prayers on his mount in whichever direction it faced, and he would also pray witr on it. However, he would not perform the obligatory prayers on it.
أخبرنا عيسى بن حماد زغبة وأحمد بن عمرو بن السرح والحارث بن مسكين قراءة عليه وأنا أسمع واللفظ له عن ابن وهب عن يونس عن ابن شهاب
كان رسول الله ﷺ يسبح على الراحلة قبل أي وجه تتوجه ويوتر عليها غير أنه لا يصلي عليها المكتوبة
Muslim narrated it in the Book of Traveler's Prayer, chapter on the permissibility of performing the voluntary prayer while riding a mount during travel in whatever direction it is facing, hadith 39/700, from the narration of Ibn Wahb. Bukhari narrated it in the Book of Shortening Prayer, chapter on dismounting for the obligatory prayer, hadith 1098, from the narration of Yunus bin Yazid, with the same wording.