File tree Expand file tree Collapse file tree
packages/astro/src/vite-plugin-astro-server Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -13,20 +13,11 @@ export function baseMiddleware(
1313 logger : Logger ,
1414) : vite . Connect . NextHandleFunction {
1515 const { config } = settings ;
16- let devRoot : string ;
17- let devRootReplacement : string ;
18- let devRootURL : URL ;
19- try {
20- const site = config . site ? new URL ( config . base , config . site ) : undefined ;
21- devRootURL = new URL ( config . base , 'http://localhost' ) ;
22- devRoot = site ? site . pathname : devRootURL . pathname ;
23- devRootReplacement = devRoot . endsWith ( '/' ) ? '/' : '' ;
24- } catch {
25- // If base is invalid, default to '/'
26- devRootURL = new URL ( '/' , 'http://localhost' ) ;
27- devRoot = '/' ;
28- devRootReplacement = '/' ;
29- }
16+ const base = config . base || '/' ;
17+ const site = config . site ? new URL ( base , config . site ) : undefined ;
18+ const devRootURL = new URL ( base , 'http://localhost' ) ;
19+ const devRoot = site ? site . pathname : devRootURL . pathname ;
20+ const devRootReplacement = devRoot . endsWith ( '/' ) ? '/' : '' ;
3021
3122 return function devBaseMiddleware ( req , res , next ) {
3223 const url = req . url ! ;
You can’t perform that action at this time.
0 commit comments