Commit 7d8100a 1 parent 4f00f58 commit 7d8100a Copy full SHA for 7d8100a
File tree 1 file changed +2
-2
lines changed
packages/vite/src/node/server/middlewares
1 file changed +2
-2
lines changed Original file line number Diff line number Diff line change @@ -78,7 +78,7 @@ export function serveStaticMiddleware(
78
78
return next ( )
79
79
}
80
80
81
- const url = new URL ( req . url ! , 'http://example.com' )
81
+ const url = new URL ( req . url ! . replace ( / ^ \/ + / , '/' ) , 'http://example.com' )
82
82
const pathname = decodeURIComponent ( url . pathname )
83
83
84
84
// apply aliases to static requests as well
@@ -125,7 +125,7 @@ export function serveRawFsMiddleware(
125
125
126
126
// Keep the named function. The name is visible in debug logs via `DEBUG=connect:dispatcher ...`
127
127
return function viteServeRawFsMiddleware ( req , res , next ) {
128
- const url = new URL ( req . url ! , 'http://example.com' )
128
+ const url = new URL ( req . url ! . replace ( / ^ \/ + / , '/' ) , 'http://example.com' )
129
129
// In some cases (e.g. linked monorepos) files outside of root will
130
130
// reference assets that are also out of served root. In such cases
131
131
// the paths are rewritten to `/@fs/` prefixed paths and must be served by
You can’t perform that action at this time.
0 commit comments