While in Mecca, the Messenger of Allah ﷺ used to pray facing Jerusalem with the Kaabah in front of him. After he migrated to Medina, he continued to do so for sixteen months, then he was directed to face the Kaabah.
حدثنا يحيى بن حماد حدثنا أبو عوانة عن الأعمش عن مجاهد
كان رسول الله ﷺ يصلي وهو بمكة نحو بيت المقدس والكعبة بين يديه وبعد ما هاجر إلى المدينة ستة عشر شهرا ثم صرف إلى الكعبة
Its isnad is sahih, and it is a longer version of 2252. It is found in Majma al-Zawaid 2:12, where it is stated, "Ahmad, Tabarani in Al-Kabir, and Bazzar reported it, and its narrators are the narrators of the Sahih." It is also found in Durr Manthur 1:142, where it is attributed as well to Ibn Abu Shayba, Abu Dawud in his Nasikh, Nahhas, and Bayhaqi.