Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev and preview are not aligned in how they serve index.html files contained under subfolders of public #16567

Closed
7 tasks done
ElliotNB opened this issue Apr 30, 2024 · 2 comments
Labels
duplicate This issue or pull request already exists

Comments

@ElliotNB
Copy link

ElliotNB commented Apr 30, 2024

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 the public folder contains an index.html file (e.g., public/admin-panel/index.html and public/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 the index.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.html

However, 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 the index.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 correct index.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 the src folder. Subfolders to the public folder are still impacted.

Reproduction

https://stackblitz.com/edit/vitejs-vite-sepev3?file=main.js

Steps to reproduce

  1. Open the re-pro URL ( https://stackblitz.com/edit/vitejs-vite-sepev3?file=main.js ).
  2. Click on Admin panel link (does not work) and observe that it serves the root index.html.
  3. Click on Admin panel link (does work) and observe that it correctly serves public/admin-panel/index.html -- displaying the "Hello world." mesage.

System Info

System:
    OS: Windows 10 10.0.19045
    CPU: (4) x64 Intel(R) Core(TM)2 Quad CPU    Q9650  @ 3.00GHz
    Memory: 6.28 GB / 16.00 GB
  Binaries:
    Node: 21.7.3 - C:\Program Files\nodejs\node.EXE
    npm: 10.5.0 - C:\Program Files\nodejs\npm.CMD
    pnpm: 8.15.6 - ~\AppData\Roaming\npm\pnpm.CMD
  Browsers:
    Edge: Chromium (123.0.2420.97)
    Internet Explorer: 11.0.19041.3636

Used Package Manager

npm

Logs

No response

Validations

Copy link

stackblitz bot commented Apr 30, 2024

Fix this issue in StackBlitz Codeflow Start a new pull request in StackBlitz Codeflow.

@sapphi-red
Copy link
Member

Duplicate of #6714

@sapphi-red sapphi-red marked this as a duplicate of #6714 May 1, 2024
@sapphi-red sapphi-red closed this as not planned Won't fix, can't repro, duplicate, stale May 1, 2024
@sapphi-red sapphi-red added duplicate This issue or pull request already exists and removed pending triage labels May 1, 2024
@github-actions github-actions bot locked and limited conversation to collaborators May 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants