Skip to content

Commit

Permalink
feat: add message
Browse files Browse the repository at this point in the history
  • Loading branch information
sapphi-red committed Oct 12, 2023
1 parent 1a64700 commit d1efcf7
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions packages/vite/src/node/server/middlewares/base.ts
Expand Up @@ -33,10 +33,12 @@ export function baseMiddleware({
})
res.end()
return
} else if (req.headers.accept?.includes('text/html')) {
// non-based page visit
const redirectPath =
withTrailingSlash(url) !== base ? joinUrlSegments(base, url) : base
}

// non-based page visit
const redirectPath =
withTrailingSlash(url) !== base ? joinUrlSegments(base, url) : base
if (req.headers.accept?.includes('text/html')) {
res.writeHead(404, {
'Content-Type': 'text/html',
})
Expand All @@ -47,11 +49,14 @@ export function baseMiddleware({
return
} else {
// not found for resources
res.writeHead(404)
res.end()
res.writeHead(404, {
'Content-Type': 'text/plain',
})
res.end(
`The server is configured with a public base URL of ${base} - ` +
`did you mean to visit ${redirectPath} instead?`,
)
return
}

next()
}
}

0 comments on commit d1efcf7

Please sign in to comment.