Is it wrong to recite a Dua upon a deceased person facing them?

Assalaam, in Medina at Masjid Al Nabwi I was stopped by the guards outside the masjid door facing his shrine reciting Al Fatiha, Dua Al Faraj, Surah Al Nasr and guards stopped me and said to face the Kaaba as I can only pray to god.

If I’m just reciting something on the persons behalf should I still face the Kaaba?