When working with Inertia UI Modals, standard Rails redirects might not behave as expected because the request originates from within a modal context. The InertiaRailsContrib::InertiaUIModal::Redirect module provides an override for redirect_back_or_to.
This method checks for the presence of the HEADER_BASE_URL in the request headers. If this header is present and the host is allowed, the redirect is sent back to the URL specified in the modal's base URL header, ensuring the user is returned to the correct underlying page rather than just the previous entry in the browser history. If the header is missing or the host is not allowed, it falls back to the standard Rails redirect_back_or_to behavior.
# This method is intended to be included in a controller context
# to enable modal-aware redirects.
redirect_back_or_to(fallback_location, allow_other_host: false, **options)