How to logout from embedded app on a different domain?

I have a portal with many apps using the same menu as a module. On that menu, i have placed a "Logout" button, which has a click-event handler, running a script -> utils.openUrl('https://portal.[domain].de/logout');

The URL is static and works, if the portal is running under the same domain.

Now i have some partners who want to put the portal login page on their own website, embedding as iframe (understood from the docs that this is one of the ways to embed an application)

So they open up by going to portal.partner1.com and they see login screen from retool portal and can login.

However, if they click to logout, due to the "utils.openUrl('https://portal.[domain].de/logout')" click event, the are redirected to this domain, instead of being redirected to portal.partner1.com/login

So, what is the best approach to keep the logout url dynamic, using an iframe to get the current URL of where the iframe lives?