diff --git a/packages/router-core/src/router.ts b/packages/router-core/src/router.ts index d2987b7a325..eb9f67113b6 100644 --- a/packages/router-core/src/router.ts +++ b/packages/router-core/src/router.ts @@ -1162,7 +1162,6 @@ export class RouterCore< maskedLocation: location, } } - return location } @@ -1966,7 +1965,12 @@ export class RouterCore< trimPath(normalizeUrl(this.latestLocation.href)) !== trimPath(normalizeUrl(nextLocation.href)) ) { - throw redirect({ href: nextLocation.href }) + let href = nextLocation.url + if (this.origin && href.startsWith(this.origin)) { + href = href.replace(this.origin, '') || '/' + } + + throw redirect({ href }) } }