File tree Expand file tree Collapse file tree
server/core/src/adapters/node/plugins Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -663,7 +663,7 @@ const rscBridgeRuntimePlugin = (): ModuleFederationRuntimePlugin => {
663663 if ( ! alias ) {
664664 return args ;
665665 }
666- void ensureRemoteAliasMerged ( alias , args ) ;
666+ await ensureRemoteAliasMerged ( alias , args ) ;
667667 return args ;
668668 } ,
669669 async onLoad ( args : any ) {
Original file line number Diff line number Diff line change @@ -260,11 +260,25 @@ export const moduleFederationSSRPlugin = (
260260 return ;
261261 }
262262 try {
263- if (
264- req . url ?. includes ( '.json' ) &&
265- ! req . url ?. includes ( 'hot-update' )
266- ) {
267- const filepath = path . join ( process . cwd ( ) , `dist${ req . url } ` ) ;
263+ const requestPath = req . url ?. split ( '?' ) [ 0 ] || '' ;
264+ const isJsonRequest = path . extname ( requestPath ) === '.json' ;
265+ if ( isJsonRequest && ! requestPath . includes ( 'hot-update' ) ) {
266+ if ( ! requestPath . startsWith ( '/' ) ) {
267+ next ( ) ;
268+ return ;
269+ }
270+
271+ const distRoot = path . resolve ( process . cwd ( ) , 'dist' ) ;
272+ const filepath = path . resolve ( distRoot , `.${ requestPath } ` ) ;
273+ const allowedPrefix = `${ distRoot } ${ path . sep } ` ;
274+ if (
275+ filepath !== distRoot &&
276+ ! filepath . startsWith ( allowedPrefix )
277+ ) {
278+ next ( ) ;
279+ return ;
280+ }
281+
268282 fs . statSync ( filepath ) ;
269283 res . setHeader ( 'Access-Control-Allow-Origin' , '*' ) ;
270284 res . setHeader (
Original file line number Diff line number Diff line change @@ -65,7 +65,7 @@ const isPromiseLike = (value: unknown): value is Promise<unknown> =>
6565 'then' in ( value as Promise < unknown > ) &&
6666 typeof ( value as Promise < unknown > ) . then === 'function' ;
6767
68- const loadBundleModule = async ( filepath : string ) : Promise < unknown > => {
68+ const loadBundleModule = ( filepath : string ) : unknown | Promise < unknown > => {
6969 try {
7070 return require ( filepath ) ;
7171 } catch ( err : any ) {
@@ -124,7 +124,7 @@ const loadBundle = async (
124124 }
125125
126126 try {
127- const module = await loadBundleModule ( filepath ) ;
127+ const module = loadBundleModule ( filepath ) ;
128128 if ( ! isPromiseLike ( module ) ) {
129129 return module ;
130130 }
You can’t perform that action at this time.
0 commit comments