The core turbo.js library does not permit cross-origin visit requests (i.e. a link that redirects to an external domain). These requests call the adapter method visitRequestFailedWithStatusCode(visit, statusCode) for all platforms.
To handle this in the browser adapter, non-HTTP status code failures update the window.location so the browser can handle the top-level redirect. The browser adapter does not actually know whether a cross-origin redirect was attempted, since the CORS policy restricts requests to the same-origin, but updating the window.location directly bypasses needing this knowledge.
The mobile adapters, however, can't just update the window.location — a new visit needs to be proposed so the native app can decide how to handle the external url request. This PR finds any potential cross-origin redirect locations when a visit request fails with a non-HTTP status code and proposes the external redirect location as a new visit.
The core
turbo.js
library does not permit cross-origin visit requests (i.e. a link that redirects to an external domain). These requests call the adapter methodvisitRequestFailedWithStatusCode(visit, statusCode)
for all platforms.To handle this in the browser adapter, non-HTTP status code failures update the
window.location
so the browser can handle the top-level redirect. The browser adapter does not actually know whether a cross-origin redirect was attempted, since the CORS policy restricts requests to thesame-origin
, but updating thewindow.location
directly bypasses needing this knowledge.The mobile adapters, however, can't just update the
window.location
— a new visit needs to be proposed so the native app can decide how to handle the external url request. This PR finds any potential cross-origin redirect locations when a visit request fails with a non-HTTP status code and proposes the external redirect location as a new visit.Fixes https://github.com/hotwired/turbo-android/issues/320