fix: dev server intercepts Vite URLs when basePath is configured (#3730)

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Bartek Iwańczuk
2026-03-29 19:42:36 +00:00
committed by GitHub
co-authored by Claude Opus 4.6
parent 14cff12fcc
commit e0ee53d458
4 changed files with 40 additions and 1 deletions
@@ -14,7 +14,13 @@ export function devServer(): Plugin[] {
publicDir = config.publicDir;
},
configureServer(server) {
const IGNORE_URLS = /^\/(@(vite|fs|id)|\.vite)\//;
// Build the ignore pattern accounting for the configured base path.
// Vite prefixes virtual module URLs with the base (e.g. /ui/@id/...),
// so we need to match both /@ and /base/@.
const base = server.config.base.replace(/\/$/, "");
const IGNORE_URLS = new RegExp(
`^(${base})?/(@(vite|fs|id)|\\.vite)/`,
);
server.middlewares.use(async (nodeReq, nodeRes, next) => {
const serverCfg = server.config.server;