From c6d451bcf00f3ea2557a145c106ab01053e953f9 Mon Sep 17 00:00:00 2001 From: MHSanaei Date: Sat, 23 May 2026 20:49:09 +0200 Subject: [PATCH] fix(frontend): resolve lazy chunk URLs against runtime base path Vite's default chunk-preload helper prepends a hardcoded `/` to asset filenames, so dynamic chunk preloads always 404 when the panel is served under a non-root webBasePath (e.g. /CxuVUNgm5mRLmjPhp3/). Use experimental.renderBuiltUrl to embed window.X_UI_BASE_PATH (injected by dist.go) as the runtime prefix, so __vite__mapDeps emits URLs like `assets/` regardless of where the dist is mounted. --- frontend/vite.config.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/frontend/vite.config.js b/frontend/vite.config.js index 2b6b5056..9a860191 100644 --- a/frontend/vite.config.js +++ b/frontend/vite.config.js @@ -152,6 +152,16 @@ export default defineConfig({ '@': path.resolve(__dirname, 'src'), }, }, + experimental: { + renderBuiltUrl(filename, { hostType }) { + if (hostType === 'js') { + return { + runtime: `((window.X_UI_BASE_PATH||'/')+${JSON.stringify(filename)})`, + }; + } + return undefined; + }, + }, build: { outDir, emptyOutDir: true,