Hello @whynot!
Thank you for the great example outline. Currently for your use case, there would be two ways for a retool iframe to be able to access information such as a URL from the website it is embedded in.
One option is to run a 'Parent Window Query' as outlined in our docs here.
You will have to build out code in the website where the iframe is embedded to grab the URL. Such as let currentURL = window.location.href;
You can also pass in the currentURL as a prop to the HTML/JSX/React component where the iframe lives in the website's code as you would with traditional JSX components. There are a number of resources online on passing data to child components. There is less support/documentation for this with retool unfortunately.
Once the retool app/iframe has access to the URL you can make the route passed in to utils.openUrl() dynamic using {{ }} to grab the current web page's URL which you received via the Parent Window Query.
With the URL stored in the app as either a javascript variable or in the app's state, it should be accessible to pass into the place where you have [domain] in your examples.
It should then be dynamic and reusable!
Not sure about how you would best handle the URL ending in either /logout or /login You would likely need another variable to control that an interpolate out with {{}} possibly a boolean.