Skip to content

Conversation

sdunster
Copy link

This PR adds logic to make SPA fallback look for a corresponding index.html for each directory component all the way down to root.

In dev mode if the browser requests /foo/bar we will try looking for an index.html like this:

  • /foo/bar/index.html
  • /foo/index.html
  • /index.html

This way if you're developing a suite of single page applications that use SPA routing you should no longer get not found errors when you refresh/go direct as posted about here.

This is my first contribution - would be great to get some indication of whether or not a PR like this is likely to be accepted before I go writing tests/updating docs - just let me know what is needed.

SPA fallback tries looking for a corresponding index.html for each directory component all the way down to root.
@bluwy
Copy link
Member

bluwy commented Sep 25, 2025

The issue with this is that not all (or many) deployment platforms support this behavior. Vite dev currently mimics the most common behavior so that it matches after you've deployed it. Can you confirm which platforms or server setups you use that may benefit from this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants