Skip to content

Commit 1f1ca88

Browse files
LuisDev2001danpeen2heal1
authored
fix(bridge-vue3): rewrite path navigations with basename in hash history mode (module-federation#4579)
Co-authored-by: quanquanfeng <dapeen.feng@gmail.com> Co-authored-by: Hanric <hanric.zhang@gmail.com>
1 parent 078855b commit 1f1ca88

6 files changed

Lines changed: 527 additions & 13 deletions

File tree

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
'@module-federation/bridge-vue3': patch
3+
---
4+
5+
feat(bridge-vue3): add afterRouterCreate callback to preserve navigation guards
6+
7+
The bridge internally recreates the Vue Router instance, which discards any
8+
global navigation guards (beforeEach, afterEach, beforeResolve) registered on
9+
the original router. The new optional `afterRouterCreate` callback in the
10+
`appOptions` return value is invoked with the bridge's internal router right
11+
after creation but before any navigation, allowing consumers to re-register
12+
their guards on the actual router that will be used.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
'@module-federation/bridge-vue3': patch
3+
---
4+
5+
fix(bridge-vue3): skip rewriting relative paths, query strings, and hash fragments in hash+basename mode
6+
7+
The `patchRouter` function created by `createHashBasenamePatch()` now only rewrites
8+
**absolute** paths (starting with `/`). Previously it blindly prefixed any string
9+
navigation, which caused:
10+
11+
- Relative paths like `router.push('settings')` to become `/barbersettings` instead of
12+
being resolved by Vue Router against the current route.
13+
- Query-only navigations like `router.push('?tab=details')` to jump to `/barber?tab=details`,
14+
dropping the current path.
15+
- Hash-only navigations like `router.push('#anchor')` to jump to `/barber#anchor`.

0 commit comments

Comments
 (0)