[GH-ISSUE #5419] [Bug]: WebBasePath conflicts with hardcoded frontend basename "/panel" causing blank panel page via Cloudflare Tunnel #3789

Closed
opened 2026-10-31 20:34:57 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @freemankevin on GitHub (Jun 17, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5419

Describe the bug

Problem Description

When accessing the 3x-ui panel through Cloudflare Tunnel, the login page loads successfully, but the panel itself shows a blank white screen. The browser console shows the following error:

<<Router basename="/panel"><Router>

Root Cause

The frontend code hardcodes the /panel path, while the backend WebBasePath is dynamically generated (either a random string like /z2YGbXMdFnZvmUfdx8 or user-defined like /panel). When these two don't match exactly, React Router fails to match the route and renders nothing.

Hardcoded Locations Found

  1. routes.tsx:43 - computeBasename() function returns ${trimmed}/panel
  2. vite.config.js:136 - Route rewrite rules check stripped === 'panel'
  3. Multiple API calls hardcode /panel/api/... paths (20+ locations)

Steps to Reproduce

  1. Install 3x-ui v3.3.1
  2. Set WebBasePath to any value (e.g., /panel or let it generate a random string)
  3. Access through Cloudflare Tunnel (or any reverse proxy)
  4. Visit https://your-domain.com/your-WebBasePath/
  5. Page shows blank white screen, console shows Router basename mismatch error

Expected Behavior

The frontend basename should dynamically read from window.X_UI_BASE_PATH or the backend configuration, instead of being hardcoded to /panel.

Environment

  • Version: 3x-ui v3.3.1
  • Deployment: Cloudflare Tunnel + local HTTP (127.0.0.1:3142)
  • Browser: Chrome/Firefox latest

Current Workaround

None available without modifying source code and recompiling, or downgrading to an older version.

Additional Context

This issue affects all users who:

  • Use Cloudflare Tunnel (or any reverse proxy) to expose the panel
  • Change the default WebBasePath from /panel to anything else
  • Have the WebBasePath auto-generated as a random string

The hardcoded /panel in the frontend makes the WebBasePath setting essentially broken for any non-default value.

How to reproduce the problem

  1. Install 3x-ui v3.3.1
  2. Set WebBasePath to any value (e.g., /panel or let it generate a random string)
  3. Access through Cloudflare Tunnel (or any reverse proxy)
  4. Visit https://your-domain.com/your-WebBasePath/
  5. Page shows blank white screen, console shows Router basename mismatch error

Expected behavior

No response

Actual behavior

No response

Relevant logs


Screenshots

No response

3x-ui version

3.1.1

Xray-core version

26.1

How did you install 3x-ui?

install.sh script

Operating system

Debian 12

Which parts of the panel are affected?

Frontend (UI / panel pages)

Browser (only if it is a UI bug)

Google Chrome Version 149.0.7827.156 (Official Build) (64-bit)

Is the panel behind a reverse proxy or CDN?

None

Before submitting

  • I searched existing issues and this bug has not been reported.
  • I am running the latest released version of 3x-ui (or have verified the bug still exists on it).
  • This bug report is written in English.
  • I have redacted any sensitive data (tokens, real domains, client UUIDs).
Originally created by @freemankevin on GitHub (Jun 17, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5419 ### Describe the bug ## Problem Description When accessing the 3x-ui panel through Cloudflare Tunnel, the login page loads successfully, but the panel itself shows a blank white screen. The browser console shows the following error: ```js <<Router basename="/panel"><Router> ``` ## Root Cause The frontend code hardcodes the `/panel` path, while the backend `WebBasePath` is dynamically generated (either a random string like `/z2YGbXMdFnZvmUfdx8` or user-defined like `/panel`). When these two don't match exactly, React Router fails to match the route and renders nothing. ## Hardcoded Locations Found 1. `routes.tsx:43` - `computeBasename()` function returns `${trimmed}/panel` 2. `vite.config.js:136` - Route rewrite rules check `stripped === 'panel'` 3. Multiple API calls hardcode `/panel/api/...` paths (20+ locations) ## Steps to Reproduce 1. Install 3x-ui v3.3.1 2. Set WebBasePath to any value (e.g., `/panel` or let it generate a random string) 3. Access through Cloudflare Tunnel (or any reverse proxy) 4. Visit `https://your-domain.com/your-WebBasePath/` 5. Page shows blank white screen, console shows Router basename mismatch error ## Expected Behavior The frontend `basename` should dynamically read from `window.X_UI_BASE_PATH` or the backend configuration, instead of being hardcoded to `/panel`. ## Environment - Version: 3x-ui v3.3.1 - Deployment: Cloudflare Tunnel + local HTTP (127.0.0.1:3142) - Browser: Chrome/Firefox latest ## Current Workaround None available without modifying source code and recompiling, or downgrading to an older version. ## Additional Context This issue affects all users who: - Use Cloudflare Tunnel (or any reverse proxy) to expose the panel - Change the default WebBasePath from `/panel` to anything else - Have the WebBasePath auto-generated as a random string The hardcoded `/panel` in the frontend makes the `WebBasePath` setting essentially broken for any non-default value. ### How to reproduce the problem 1. Install 3x-ui v3.3.1 2. Set WebBasePath to any value (e.g., `/panel` or let it generate a random string) 3. Access through Cloudflare Tunnel (or any reverse proxy) 4. Visit `https://your-domain.com/your-WebBasePath/` 5. Page shows blank white screen, console shows Router basename mismatch error ### Expected behavior _No response_ ### Actual behavior _No response_ ### Relevant logs ```shell ``` ### Screenshots _No response_ ### 3x-ui version 3.1.1 ### Xray-core version 26.1 ### How did you install 3x-ui? install.sh script ### Operating system Debian 12 ### Which parts of the panel are affected? Frontend (UI / panel pages) ### Browser (only if it is a UI bug) Google Chrome Version 149.0.7827.156 (Official Build) (64-bit) ### Is the panel behind a reverse proxy or CDN? None ### Before submitting - [x] I searched [existing issues](../issues?q=is%3Aissue) and this bug has not been reported. - [x] I am running the latest released version of 3x-ui (or have verified the bug still exists on it). - [x] This bug report is written in English. - [x] I have redacted any sensitive data (tokens, real domains, client UUIDs).
bsakaguchi 2026-10-31 20:34:57 +07:00
Author
Owner

@github-actions[bot] commented on GitHub (Jun 17, 2026):

This is a duplicate of #5283 (and the subsequently closed #5391), which document the same root cause and confirmed fix.

The reporter's framing — that the frontend hardcodes /panel — is a misdiagnosis. computeBasename() in frontend/src/routes.tsx (lines 38-42) does read window.X_UI_BASE_PATH dynamically. The backend correctly injects the right value into every served HTML page at runtime (internal/web/controller/dist.go, lines 112-119). The injection is being blocked before it executes.

Actual root cause: Cloudflare Rocket Loader breaks the CSP nonce

  1. internal/web/middleware/security.go (line 21) generates a fresh random nonce per request and places it in the Content-Security-Policy header: script-src 'self' 'nonce-<random>'.
  2. internal/web/controller/dist.go (line 113) injects a small inline script into the served HTML with that same nonce, setting window.X_UI_BASE_PATH.
  3. Cloudflare Rocket Loader intercepts all script tags to defer their execution and strips the nonce attribute in the process. The browser then rejects the re-execution because the nonce no longer matches the CSP header. This is the rocket-loader.min.js: Executing inline script violates the following Content Security Policy directive error that appears in the browser console in all three reports.
  4. Because the script never runs, window.X_UI_BASE_PATH is never set. computeBasename() falls back to '/' (routes.tsx line 39, || '/'), producing basename="/panel". The browser URL is /your-base-path/panel/, which does not start with /panel, so React Router renders nothing — blank screen.

Fix

Disable Cloudflare Rocket Loader for your domain in the Cloudflare dashboard: Speed > Optimization > Content Optimization > Rocket Loader — toggle off. To limit the scope, create a Page Rule matching yourdomain.com/* with the action Rocket Loader: Off.

This was the confirmed fix for #5283 (same version, same console errors).

This reply was generated automatically; a maintainer may follow up.

<!-- gh-comment-id:4733700140 --> @github-actions[bot] commented on GitHub (Jun 17, 2026): This is a duplicate of #5283 (and the subsequently closed #5391), which document the same root cause and confirmed fix. The reporter's framing — that the frontend hardcodes `/panel` — is a misdiagnosis. `computeBasename()` in `frontend/src/routes.tsx` (lines 38-42) does read `window.X_UI_BASE_PATH` dynamically. The backend correctly injects the right value into every served HTML page at runtime (`internal/web/controller/dist.go`, lines 112-119). The injection is being blocked before it executes. **Actual root cause: Cloudflare Rocket Loader breaks the CSP nonce** 1. `internal/web/middleware/security.go` (line 21) generates a fresh random nonce per request and places it in the `Content-Security-Policy` header: `script-src 'self' 'nonce-<random>'`. 2. `internal/web/controller/dist.go` (line 113) injects a small inline script into the served HTML with that same nonce, setting `window.X_UI_BASE_PATH`. 3. Cloudflare Rocket Loader intercepts all script tags to defer their execution and strips the `nonce` attribute in the process. The browser then rejects the re-execution because the nonce no longer matches the CSP header. This is the `rocket-loader.min.js: Executing inline script violates the following Content Security Policy directive` error that appears in the browser console in all three reports. 4. Because the script never runs, `window.X_UI_BASE_PATH` is never set. `computeBasename()` falls back to `'/'` (routes.tsx line 39, `|| '/'`), producing `basename="/panel"`. The browser URL is `/your-base-path/panel/`, which does not start with `/panel`, so React Router renders nothing — blank screen. **Fix** Disable Cloudflare Rocket Loader for your domain in the Cloudflare dashboard: **Speed > Optimization > Content Optimization > Rocket Loader** — toggle off. To limit the scope, create a Page Rule matching `yourdomain.com/*` with the action **Rocket Loader: Off**. This was the confirmed fix for #5283 (same version, same console errors). *This reply was generated automatically; a maintainer may follow up.*
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MHSanaei/3x-ui#3789
No description provided.