Skip to content

Commit

Permalink
fix: skip redirect and error fallback on middleware mode (vitejs#4057)
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu authored and aleclarson committed Nov 8, 2021
1 parent f9fafe4 commit 9607f3e
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/vite/src/node/server/middlewares/base.ts
Expand Up @@ -19,7 +19,15 @@ export function baseMiddleware({
// rewrite url to remove base.. this ensures that other middleware does
// not need to consider base being prepended or not
req.url = url.replace(base, '/')
} else if (path === '/' || path === '/index.html') {
return next()
}

// skip redirect and error fallback on middleware mode, #4057
if (config.server.middlewareMode) {
return next()
}

if (path === '/' || path === '/index.html') {
// redirect root visit to based url
res.writeHead(302, {
Location: base
Expand Down

0 comments on commit 9607f3e

Please sign in to comment.