The most correct solution for this problem, is to have consistent SIDs to your Logins across all your SQL Servers.
So that even when a database is moved to a different server, it could still use the same SID that it was originally created for.
And also, when you recreate a previously deleted Login, you’d need to create it with the same SID that it originally had.
This is, obviously, not a trivial matter, and not always possible.
But if this is a direction that interests you, then you will find the following very useful:
Read on for the best solution, as well as the second-best solution using sp_change_users_login.