Dev and preview are not aligned in how they serve index.html files contained under subfolders of public
#16567
Closed
7 tasks done
Labels
duplicate
This issue or pull request already exists
public
#16567
Describe the bug
I have a project with static HTML and CSS assets stored in a subfolder under the
public
folder (e.g.,public/admin-panel/
,public/reports/
). Each subfolder under thepublic
folder contains anindex.html
file (e.g.,public/admin-panel/index.html
andpublic/reports/index.html
).If I build my application (
npm run build
-- aka,vite build
) and serve up the preview (npm run serve
-- aka,vite preview
), then theindex.html
file is served up correctly regardless of whether I access the file via http://localhost:4173/admin-panel/ or http://localhost:4173/admin-panel/index.htmlHowever, if I start up my application using
npm run dev
(aka,vite
), then it does not behave the same. If I visit http://localhost:5173/admin-panel/ then it will instead serve theindex.html
file contained in the root folder of my project. Only if I visit http://localhost:5173/admin-panel/index.html will it then serve up the correctindex.html
file.A similar bug was patched back in October 2023 ( #14756 ) but it appears to have only been applied to
index.html
files contained in subfolders under thesrc
folder. Subfolders to thepublic
folder are still impacted.Reproduction
https://stackblitz.com/edit/vitejs-vite-sepev3?file=main.js
Steps to reproduce
Admin panel link (does not work)
and observe that it serves the rootindex.html
.Admin panel link (does work)
and observe that it correctly servespublic/admin-panel/index.html
-- displaying the "Hello world." mesage.System Info
Used Package Manager
npm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: