From 721f94ddacdc8cbc4342a9c791d7fecba5a0f7ca Mon Sep 17 00:00:00 2001 From: Senao <48955231+XiSenao@users.noreply.github.com> Date: Thu, 18 Apr 2024 23:46:03 +0800 Subject: [PATCH] fix: add base to virtual html (#16442) --- packages/vite/src/node/server/middlewares/indexHtml.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/vite/src/node/server/middlewares/indexHtml.ts b/packages/vite/src/node/server/middlewares/indexHtml.ts index 5d06f1292b87fa..b5893dd072b972 100644 --- a/packages/vite/src/node/server/middlewares/indexHtml.ts +++ b/packages/vite/src/node/server/middlewares/indexHtml.ts @@ -191,7 +191,7 @@ const devHtmlHook: IndexHtmlTransformHook = async ( const trailingSlash = htmlPath.endsWith('/') if (!trailingSlash && getFsUtils(config).existsSync(filename)) { proxyModulePath = htmlPath - proxyModuleUrl = joinUrlSegments(base, htmlPath) + proxyModuleUrl = proxyModulePath } else { // There are users of vite.transformIndexHtml calling it with url '/' // for SSR integrations #7993, filename is root for this case @@ -202,6 +202,7 @@ const devHtmlHook: IndexHtmlTransformHook = async ( proxyModulePath = `\0${validPath}` proxyModuleUrl = wrapId(proxyModulePath) } + proxyModuleUrl = joinUrlSegments(base, proxyModuleUrl) const s = new MagicString(html) let inlineModuleIndex = -1