Skip to content

Commit 61165f0

Browse files
author
sun0day
authoredNov 20, 2022
fix(mpa): support mpa fallback (#10985)
fixes #10966
1 parent 892916d commit 61165f0

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed
 

‎packages/vite/src/node/server/middlewares/htmlFallback.ts

+3-5
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,15 @@ export function htmlFallbackMiddleware(
1414
rewrites: [
1515
{
1616
from: /\/$/,
17-
to({ parsedUrl }: any) {
17+
to({ parsedUrl, request }: any) {
1818
const rewritten =
1919
decodeURIComponent(parsedUrl.pathname) + 'index.html'
2020

2121
if (fs.existsSync(path.join(root, rewritten))) {
2222
return rewritten
23-
} else {
24-
if (spaFallback) {
25-
return `/index.html`
26-
}
2723
}
24+
25+
return spaFallback ? `/index.html` : request.url
2826
}
2927
}
3028
]

0 commit comments

Comments
 (0)
Please sign in to comment.