From 0bd8deff1c721d141d389f5934586b4cb36e13f5 Mon Sep 17 00:00:00 2001 From: bent10 Date: Thu, 25 Apr 2024 08:08:13 +0700 Subject: [PATCH] fix: improve URL handling where req.url is undefined or empty --- packages/vite/src/serve.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/vite/src/serve.ts b/packages/vite/src/serve.ts index 6aa89c7..ebda493 100644 --- a/packages/vite/src/serve.ts +++ b/packages/vite/src/serve.ts @@ -70,7 +70,10 @@ export default function serve(): Plugin { } if (req.headers['sec-fetch-dest'] === 'document') { - let route = api.getRoute(server.config.base + req.url?.slice(1)) + let route = api.getRoute( + server.config.base + + (req.url?.slice(1) || `index${api.routesConfig.urlSuffix}`) + ) let statusCode = 200 // @todo add option to handle error 404