I saw the Prophet ﷺ praying on his mount in whatever direction it faced him.In another narration, I saw the Messenger of Allah ﷺ on his mount performing voluntary prayer, gesturing with his head toward whatever direction it faced. But the Messenger of Allah ﷺ would not do this in the obligatory prayer.
رأيت النبي ﷺ يصلي على راحلته حيث توجهت به. وفي رواية: رأيت رسول الله ﷺ وهو على راحلته يسبح، يومى برأسه قبل أي وجه توجه، ولم يكن رسول الله ﷺ يصنع ذلك في الصلاة المكتوبة.
Bukhari narrated it in "Shortening the Prayer" (1093, 1097, 1104), and this is his wording, and Muslim narrated it in "The Prayer of Travelers" (701), both from the hadith of Zuhri, from Abdullah bin Amir bin Rabia, who said, then he related it.