Skip to content

Commit 088a429

Browse files
committed
refactor(router-core): handle cross-origin navigation when origins differ
Signed-off-by: leesb971204 <[email protected]>
1 parent 1a8c5e5 commit 088a429

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

packages/router-core/src/router.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1917,6 +1917,17 @@ export class RouterCore<
19171917
} catch {}
19181918
}
19191919

1920+
if (!reloadDocument) {
1921+
const nextLocation = this.buildLocation({ to, href, ...rest } as any)
1922+
const currentOrigin = new URL(this.latestLocation.url).origin
1923+
const nextOrigin = new URL(nextLocation.url).origin
1924+
1925+
if (currentOrigin !== nextOrigin) {
1926+
reloadDocument = true
1927+
href = nextLocation.url
1928+
}
1929+
}
1930+
19201931
if (reloadDocument) {
19211932
if (!href) {
19221933
const location = this.buildLocation({ to, ...rest } as any)

0 commit comments

Comments
 (0)