diff --git a/packages/vite/src/node/server/index.ts b/packages/vite/src/node/server/index.ts index bec44dafb25910..bc0b350bab5c82 100644 --- a/packages/vite/src/node/server/index.ts +++ b/packages/vite/src/node/server/index.ts @@ -621,6 +621,16 @@ export async function _createServer( _shortcutsOptions: undefined, } + const reflexServer = new Proxy(server, { + get: (_, property: keyof ViteDevServer) => { + return server[property] + }, + set: (_, property: keyof ViteDevServer, value: never) => { + server[property] = value + return true + }, + }) + if (!middlewareMode) { exitProcess = async () => { try { @@ -714,7 +724,7 @@ export async function _createServer( // apply server configuration hooks from plugins const postHooks: ((() => void) | void)[] = [] for (const hook of config.getSortedPluginHooks('configureServer')) { - postHooks.push(await hook(server)) + postHooks.push(await hook(reflexServer)) } // Internal middlewares ------------------------------------------------------