Skip to content

Commit

Permalink
fix: ensure transformIndexHtml url is relative to config.root
Browse files Browse the repository at this point in the history
  • Loading branch information
aleclarson committed May 7, 2024
1 parent 9a097d5 commit 8be0cd8
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/vite/src/node/server/middlewares/indexHtml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,14 @@ export function indexHtmlMiddleware(
try {
let html = await fsp.readFile(filePath, 'utf-8')
if (isDev) {
html = await server.transformIndexHtml(url, html, req.originalUrl)
const resolvedUrl =
'/' + path.relative(server.config.root, filePath)

html = await server.transformIndexHtml(
resolvedUrl,
html,
req.originalUrl,
)
}
return send(req, res, html, 'html', { headers })
} catch (e) {
Expand Down

0 comments on commit 8be0cd8

Please sign in to comment.