19 lines
804 B
TypeScript
19 lines
804 B
TypeScript
/**
|
|
* Transport-only path classification. Kept free of route imports so the
|
|
* lightweight IPC registration path does not eagerly load every Host API
|
|
* service before the first window is painted.
|
|
*/
|
|
export function shouldUseLoopbackHostApi(path: string, method = 'GET'): boolean {
|
|
const normalizedMethod = method.toUpperCase();
|
|
const pathname = path.split('?', 1)[0] || path;
|
|
if (pathname === '/api/events' || pathname === '/api/opencode/events') return true;
|
|
if (pathname.startsWith('/api/ai-proxy/')) return true;
|
|
if (pathname.includes('/events') && pathname.startsWith('/api/image-workspace/')) return true;
|
|
if (
|
|
pathname.includes('/assets/')
|
|
&& pathname.endsWith('/content')
|
|
&& (normalizedMethod === 'GET' || normalizedMethod === 'HEAD')
|
|
) return true;
|
|
return false;
|
|
}
|