Dynamically redirect to SSO connection string

Hi. I tried to search on the internet how to solve this problem that we have and found nothing.

Currently, we have an auth0 single tenant and we’re migrating to 2 tenants to split prod and dev.
In the production tenant, we have a custom login page where we have some manual changes to conditionally define SSO strings based on some logic we have in our backend.

Now, I want to know if it’s possible to achieve this same behavior using the Universal Login Page.

The question is: is there a functionality I can use to perform some logic before login? This would be to run the logic on the backend and return the database connection string to use. For example, an Enterprise-Connection that points to a Google Workspace config.

Also, if this is possible, what would be the best way to handle the redirect for this SSO page and redirect it to our login page?

Thanks in advance.