feat: support reverse-proxy URL subpaths (llama-swap, SwarmUI) (#1122)

This commit is contained in:
Will Miao
2026-09-24 08:04:00 +08:00
parent 755e1a5bca
commit 2f9bd3ee7d
42 changed files with 731 additions and 103 deletions
@@ -0,0 +1,28 @@
import { describe, it, expect, afterEach } from 'vitest';
import { getComfyUIBasePath, lmUrl } from '../../../web/comfyui/base_path.js';
describe('web/comfyui/base_path.js', () => {
afterEach(() => {
window.history.replaceState({}, '', '/');
});
it.each([
['/', ''],
['/comfyui/', '/comfyui'],
['/comfyui', '/comfyui'],
['/ComfyBackendDirect/', '/ComfyBackendDirect'],
])('maps %s to base path %s', (pathname, expected) => {
window.history.replaceState({}, '', pathname);
expect(getComfyUIBasePath()).toBe(expected);
});
it('builds prefixed URLs', () => {
window.history.replaceState({}, '', '/comfyui/');
expect(lmUrl('/api/lm/version-info')).toBe('/comfyui/api/lm/version-info');
expect(lmUrl('/loras')).toBe('/comfyui/loras');
window.history.replaceState({}, '', '/');
expect(lmUrl('/api/lm/version-info')).toBe('/api/lm/version-info');
});
});