Skip to content

Commit 710f5cc

Browse files
committed
fix(react-router): handle cross-origin navigation in Transitioner component
Signed-off-by: leesb971204 <[email protected]>
1 parent 5f52ff8 commit 710f5cc

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

packages/react-router/src/Transitioner.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,16 @@ export function Transitioner() {
5656
const nextPublicHref = trimPathRight(nextLocation.publicHref)
5757

5858
if (latestPublicHref !== nextPublicHref) {
59+
const latestOrigin = new URL(router.latestLocation.url).origin
60+
const nextOrigin = new URL(nextLocation.url).origin
61+
62+
if (latestOrigin !== nextOrigin) {
63+
if (typeof window !== 'undefined') {
64+
window.location.href = nextLocation.url
65+
}
66+
return
67+
}
68+
5969
router.commitLocation({ ...nextLocation, replace: true })
6070
}
6171

0 commit comments

Comments
 (0)