No back button in error screen due to broker not having baseURL

I have a Keycloak client “X” which users login with, and this client uses an Identity Provider Broker to allow an alternative sign on method. When this sign-on method is used and an error occurs, there is no back button provided to return to the login screen.

I have examined the error.tpl file and found this snippet:

<#if client?? && client.baseUrl?has_content>
                <p><a id="backToApplication" href="${client.baseUrl}">${kcSanitize(msg("backToApplication"))?no_esc}</a></p>
            </#if>

Which requires a baseUrl to be set for the client.

I have set a baseUrl for client X, but this does not exist when I use the alternative IDP authentication method. I believe this is because it switches to the “broker”, which does not have a baseUrl. See the following URL snippet which is used when you login using the alternative method.

/broker/alternative-login-thing/endpoint/start?state=dZWqYe0cPCSfSlTVWasasiA92PF3JJOyTeKSiC5_bdsksd2aJT0.dkS012knko.security-admin-console

I cannot hardcode the back button, because multiple clients use this alternative login flow and all have different baseUrls.

Can I somehow “pass on” the baseUrl from client X to the broker IDP flow so that a back button can be successfully displayed?

Thanks!