Fallback for SPA should support files other than index.html
Author: nktnet1Created Jun 25, 2026Updated Jun 25, 2026
Description
Currently, there is the following option (mentioned in #664):
-s, --single Rewrite all not-found requests to `index.html`However, this option is limited and does not support loading custom HTML as mentioned by @woss in:
Why
Frameworks like Tanstack Start generates _shell.html by default for SPA, rather than index.html:
Alternatives
A workaround can be seen here:
Where serve.json is created with a rewrite:
{
"rewrites": [
{
"source": "!/api/**",
"destination": "/_shell.html"
}
]
}This isn't ideal, however, since the rewrite works on all paths rather than serving as a fallback, which masks the API route - thus, it needs to be excluded in the source glob. There may also be other exclusions needed apart from /api.
Source: vercel/serve