File tree Expand file tree Collapse file tree 3 files changed +23
-9
lines changed
plugin-router-v5/src/runtime
plugin-runtime/src/router/runtime Expand file tree Collapse file tree 3 files changed +23
-9
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ ' @modern-js/runtime ' : patch
3
+ ---
4
+
5
+ fix: router plugin baseUrl not work
6
+
7
+ fix: router 插件 baseUrl 不生效
Original file line number Diff line number Diff line change @@ -165,14 +165,18 @@ export const routerPlugin = (userConfig: RouterConfig = {}): Plugin => {
165
165
const location = getLocation ( ssrContext ) ;
166
166
const routerContext = ssrContext ?. redirection || { } ;
167
167
const request = ssrContext ?. request ;
168
- const baseUrl = (
169
- runtimeContext . _internalRouterBaseName ||
170
- ( request ?. baseUrl as string )
171
- ) ?. replace ( / ^ \/ * / , '/' ) ;
168
+ const baseUrl = ( request ?. baseUrl as string ) ?. replace (
169
+ / ^ \/ * / ,
170
+ '/' ,
171
+ ) ;
172
172
173
173
const basename =
174
174
baseUrl === '/'
175
- ? urlJoin ( baseUrl , historyOptions . basename as string )
175
+ ? urlJoin (
176
+ baseUrl ,
177
+ runtimeContext . _internalRouterBaseName ||
178
+ ( historyOptions . basename as string ) ,
179
+ )
176
180
: baseUrl ;
177
181
const runner = ( api as any ) . useHookRunners ( ) ;
178
182
const routes = runner . modifyRoutes ( originRoutes ) ;
Original file line number Diff line number Diff line change @@ -92,12 +92,15 @@ export const routerPlugin = (
92
92
* basename: modern config file config
93
93
*/
94
94
const baseUrl = (
95
- runtimeContext . _internalRouterBaseName ||
96
- window . _SERVER_DATA ?. router . baseUrl ||
97
- select ( location . pathname )
95
+ window . _SERVER_DATA ?. router . baseUrl || select ( location . pathname )
98
96
) . replace ( / ^ \/ * / , '/' ) ;
99
97
const _basename =
100
- baseUrl === '/' ? urlJoin ( baseUrl , basename ) : baseUrl ;
98
+ baseUrl === '/'
99
+ ? urlJoin (
100
+ baseUrl ,
101
+ runtimeContext . _internalRouterBaseName || basename ,
102
+ )
103
+ : baseUrl ;
101
104
102
105
let hydrationData = window . _ROUTER_DATA ;
103
106
You can’t perform that action at this time.
0 commit comments