Skip to content

Commit 60fe476

Browse files
committed
fix: fix spa fallback on paths ending with slash
1 parent a7a5c5b commit 60fe476

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

packages/vite/src/node/server/index.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,12 @@ export async function createServer(
313313
{
314314
from: /\/$/,
315315
to({ parsedUrl }: any) {
316-
return parsedUrl.pathname + 'index.html'
316+
const rewritten = parsedUrl.pathname + 'index.html'
317+
if (fs.existsSync(path.join(root, rewritten))) {
318+
return rewritten
319+
} else {
320+
return `/index.html`
321+
}
317322
}
318323
}
319324
]

0 commit comments

Comments
 (0)