Skip to content

Commit b24d155

Browse files
[backport core/1.33] fix: subpath routing for reverse proxy, embedded frontends, nginx/apache subpath hosting, etc. (like SwarmUI) (#7116)
Backport of #7115 to `core/1.33` Automatically created by backport workflow. ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-7116-backport-core-1-33-fix-subpath-routing-for-reverse-proxy-embedded-frontends-nginx-ap-2be6d73d36508125a7cdf11672203e88) by [Unito](https://www.unito.io) Co-authored-by: Christian Byrne <cbyrne@comfy.org>
1 parent cb50a45 commit b24d155

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/router.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,17 @@ import { cloudOnboardingRoutes } from './platform/cloud/onboarding/onboardingClo
2020

2121
const isFileProtocol = window.location.protocol === 'file:'
2222

23-
// Determine base path for the router
24-
// - Electron: always root
25-
// - Web: rely on Vite's BASE_URL (configured via vite.config `base`)
23+
/**
24+
* Determine base path for the router.
25+
* - Electron: always root
26+
* - Cloud: use Vite's BASE_URL (configured at build time)
27+
* - Standard web (including reverse proxy subpaths): use window.location.pathname
28+
* to support deployments like http://mysite.com/ComfyUI/
29+
*/
2630
function getBasePath(): string {
2731
if (isElectron()) return '/'
28-
// Vite injects BASE_URL at build/dev time; default to '/'
29-
return import.meta.env?.BASE_URL || '/'
32+
if (isCloud) return import.meta.env?.BASE_URL || '/'
33+
return window.location.pathname
3034
}
3135

3236
const basePath = getBasePath()

0 commit comments

Comments
 (0)