From e6bef229ae4b65a7aa4c3ec95c495239c06ec607 Mon Sep 17 00:00:00 2001 From: MHSanaei Date: Sat, 11 Jul 2026 21:58:23 +0200 Subject: [PATCH] fix(web): opt panel pages out of Cloudflare Rocket Loader Behind Cloudflare with Rocket Loader enabled, the panel's entry bundles were rewritten and executed through Rocket Loader's own loader instead of as native ES modules (a reporter's network capture shows the main bundle initiated by rocket-loader.min.js). That breaks module semantics and script ordering, leaving a blank page after login even though every asset returns 200 - most visibly with a custom URI path, where the injected base path must be set before the bundle boots. Stamp data-cfasync="false" - Cloudflare's documented per-script opt-out - on the built entry script tags via a build-time transformIndexHtml hook (Vite regenerates entry tags, so a source-HTML attribute would be stripped), and on the runtime-injected base-path/version inline script in serveDistPage. Closes #5868 --- frontend/vite.config.js | 14 +++++++++++++- internal/web/controller/dist.go | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/frontend/vite.config.js b/frontend/vite.config.js index 4c97971ea..f16d215b5 100644 --- a/frontend/vite.config.js +++ b/frontend/vite.config.js @@ -77,6 +77,18 @@ function injectBasePathPlugin() { }; } +// Cloudflare Rocket Loader rewrites script tags and runs bundles through its +// own loader, breaking ES-module semantics; data-cfasync="false" opts out. +function rocketLoaderOptOutPlugin() { + return { + name: 'xui-rocket-loader-opt-out', + apply: 'build', + transformIndexHtml(html) { + return html.replaceAll('