diff --git a/src/router.ts b/src/router.ts index d1291e079b..5ffd5a1af9 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()