Whenever the Messenger of Allah ﷺ went out on the day of Eid, he would order a spear to be brought and placed in front of him. He would then pray facing it, with the people praying behind him. He used to do this while traveling, and from that practice the rulers adopted it.
حدثنا الحسن بن علي حدثنا ابن نمير عن عبيد الله عن نافع
أن رسول الله ﷺ كان إذا خرج يوم العيد أمر بالحربة فتوضع بين يديه فيصلي إليها والناس وراءه وكان يفعل ذلك في السفر فمن ثم اتخذها الأمراء
Bukhari narrated it in the chapters on the worshipper's screen, chapter, the imam's screen is a screen for those behind him, no. 494, and Muslim in the book of prayer, chapter, the worshipper's screen and the recommendation to pray towards a screen etc., no. 501, from the hadith of Abdullah bin Numayr, with this wording.