fix: allow programmatic visits to go cross-origin #410
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently, when calling
Turbo.visit("https://example.com", { action: "advance" })
, the site will not navigate to thehttps://example.com
and in addition a number of errors pop up here:Most of these errors have to do with trying to fetch cross-origin as well as adding history for a cross-origin url. This PR takes previous art from Turbolinks here:
https://github.com/turbolinks/turbolinks/blob/80cd172ed5b3a35eda85c58e428de9f1f1d06fc8/src/controller.ts#L70-L80
and uses previous art from Turbo's own link delegator here:
turbo/src/core/session.ts
Lines 334 to 336 in 5982a67
Unfortunately, I ran into multiple issues trying to get tests for this due to my chromedriver only supporting up to v92 and chrome itself being v94. I tried manually installing and upgrading both and was unsuccessful. Regardless, I think drawing on prior art and having done some manual testing as well, all appears to be well.
Video Before:
Screen.Recording.2021-09-27.at.11.06.50.PM.mov
Video After:
Screen.Recording.2021-09-27.at.11.04.12.PM.mov