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

Vite dev doesn't serve index.html from subdirectories of publicDir #17537

Closed
7 tasks done
dhdaines opened this issue Jun 20, 2024 · 1 comment
Closed
7 tasks done

Vite dev doesn't serve index.html from subdirectories of publicDir #17537

dhdaines opened this issue Jun 20, 2024 · 1 comment

Comments

@dhdaines
Copy link

Describe the bug

Vite's dev server behaviour for directories is subtly and maddeningly different for directories in root versus directories in publicDir. As described in great detail in the migration guide the behaviour is now consistent between dev and preview for root and depends on the presence of a trailing slash: /dir/ will route to /dir/index.html while /dir will route to /index.html.

For publicDir something else happens, namely that anything that isn't a specifically existing file seems to get routed to /index.html (like a SPA).

This behaviour doesn't seem to be documented anywhere, is inconsistent and not what I, a user, expect :-)

Reproduction

https://github.com/dhdaines/vitebug

Steps to reproduce

System Info

System:
    OS: Linux 6.1 Debian GNU/Linux 12 (bookworm) 12 (bookworm)
    CPU: (4) x64 Intel(R) Core(TM) i5-5300U CPU @ 2.30GHz
    Memory: 2.62 GB / 7.46 GB
    Container: Yes
    Shell: 5.2.15 - /bin/bash
  Binaries:
    Node: 20.14.0 - ~/.nvm/versions/node/v20.14.0/bin/node
    npm: 10.7.0 - ~/.nvm/versions/node/v20.14.0/bin/npm
  Browsers:
    Chrome: 126.0.6478.61
  npmPackages:
    vite: ^5.2.0 => 5.3.1

Used Package Manager

npm

Logs

Log for /foo/
  vite:html-fallback Rewriting GET /foo/ to /index.html +0ms
  vite:time 41.09ms /index.html +51ms                                      
Log for /bar/
  vite:html-fallback Rewriting GET /bar/ to /bar/index.html +1m
  vite:time 7.54ms /bar/index.html +1m

Validations

@bluwy
Copy link
Member

bluwy commented Jun 21, 2024

Duplicate of #6714

@bluwy bluwy marked this as a duplicate of #6714 Jun 21, 2024
@bluwy bluwy closed this as not planned Won't fix, can't repro, duplicate, stale Jun 21, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Jul 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants