From a286c4137b00661f2e559514f51e0d6d7ce0c11e Mon Sep 17 00:00:00 2001 From: bymyself Date: Tue, 2 Dec 2025 17:16:47 -0800 Subject: [PATCH] fix subpath routing on local --- src/router.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/router.ts b/src/router.ts index d1291e079b4..5ffd5a1af9b 100644 --- a/src/router.ts +++ b/src/router.ts @@ -20,13 +20,17 @@ import { cloudOnboardingRoutes } from './platform/cloud/onboarding/onboardingClo const isFileProtocol = window.location.protocol === 'file:' -// Determine base path for the router -// - Electron: always root -// - Web: rely on Vite's BASE_URL (configured via vite.config `base`) +/** + * Determine base path for the router. + * - Electron: always root + * - Cloud: use Vite's BASE_URL (configured at build time) + * - Standard web (including reverse proxy subpaths): use window.location.pathname + * to support deployments like http://mysite.com/ComfyUI/ + */ function getBasePath(): string { if (isElectron()) return '/' - // Vite injects BASE_URL at build/dev time; default to '/' - return import.meta.env?.BASE_URL || '/' + if (isCloud) return import.meta.env?.BASE_URL || '/' + return window.location.pathname } const basePath = getBasePath()