From e758ac3057f803dcf148e058cff94743d21ff91e Mon Sep 17 00:00:00 2001 From: Hanxing Yang Date: Wed, 1 Jan 2025 22:36:56 +0800 Subject: [PATCH] fix(vite): add configured headers for devtool-related response (#710) --- packages/vite/src/vite.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/vite/src/vite.ts b/packages/vite/src/vite.ts index 47a65314..3153094a 100644 --- a/packages/vite/src/vite.ts +++ b/packages/vite/src/vite.ts @@ -95,6 +95,15 @@ export default function VitePluginVueDevTools(options?: VitePluginVueDevToolsOpt server.middlewares.use(`${base}__devtools__`, sirv(DIR_CLIENT, { single: true, dev: true, + setHeaders(response) { + if (config.server.headers == null) + return + Object.entries(config.server.headers).forEach(([key, value]) => { + if (value == null) + return + response.setHeader(key, value) + }) + }, })) // vite client <-> server messaging