The Messenger of Allah ﷺ used to pray while in Mecca facing Bayt al-Maqdis, with the Kaabah between him and his direction of prayer. After he migrated to Medina, he continued doing so for sixteen months, then he was turned to face the Kaabah.
كان رسول الله ﷺ يصلي وهو بمكة نحو بيت المقدس، والكعبة بين يديه، وبعدما هاجر إلى المدينة ستة عشر شهرا، ثم صرف إلى الكعبة.
Ahmad (2991), Bazzar (Kashf Astar, 418), and Tabarani in Al-Kabir (11/67) all narrated it through Yahya bin Hammad, who said, "Abu Awana told us, from Amash, from Mujahid, from Ibn Abbas," and he mentioned it. Its isnad is sahih. Abu Awana is Wadhah bin Abdullah Yashkuri Bazzaz, well known by his kunya.