Skip to content

Commit

Permalink
fix(mpa): support mpa fallback (#10985)
Browse files Browse the repository at this point in the history
fixes #10966
  • Loading branch information
sun0day committed Nov 20, 2022
1 parent 892916d commit 61165f0
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions packages/vite/src/node/server/middlewares/htmlFallback.ts
Expand Up @@ -14,17 +14,15 @@ export function htmlFallbackMiddleware(
rewrites: [
{
from: /\/$/,
to({ parsedUrl }: any) {
to({ parsedUrl, request }: any) {
const rewritten =
decodeURIComponent(parsedUrl.pathname) + 'index.html'

if (fs.existsSync(path.join(root, rewritten))) {
return rewritten
} else {
if (spaFallback) {
return `/index.html`
}
}

return spaFallback ? `/index.html` : request.url
}
}
]
Expand Down

0 comments on commit 61165f0

Please sign in to comment.