How to get the right shop in app

I have an app in which I have to get shop data and display relevant stuff on the front end. I get the correct shop by getting the current url and looking up from using that.

const shop = request.headers.get(‘origin’).split(“//”)[1]> const session = await prisma.sessions.findMany({> where: {> shop: shop> }> })
While this works in most cases, it breaks if the store owner changes domain post installation as I cant find the session anymore. Is there a better and more breakage free way to handle this situation?