The behavior you are seeing is expected if the original URL is not preserved before the SAML authentication flow starts.
A pattern I have implemented for similar use cases is:
window.location.href) before starting SSO.I do not believe the SAML20 module automatically honors an arbitrary r parameter on /SSO/discovery as a post-login return URL. In most projects I have worked on, this requires custom handling of the original request URL.
Another option worth considering is the Mendix Deep Link module. If your target page can be represented as a Deep Link, Mendix can handle routing more cleanly after authentication.
Kindly mark this as the accepted answer if it helps.
Hi Johan
Try Remove Guest/Anonymous role access from the target page.Once the page requires authentication, Mendix will Capture the original /p/page .... URL and Trigger SAML SSO automatically and Redirect back to the original URL after successful login.
but if it didnt work then and still redirects to homepage, the only reliable workaround is the login.html client-side approach in your index.html
// In login.html — before redirect to /SSO/
sessionStorage.setItem('postLoginUrl', window.location.href);
// After login completes
window.mx.afterLoginAction = function() {
var target = sessionStorage.getItem('postLoginUrl');
if (target) {
sessionStorage.removeItem('postLoginUrl');
window.location = target;
}
};
paste this code This captures the original URL before SSO kicks in and restores it after. This approach works regardless of platform limitations.