mirror of
https://github.com/tiennm99/ccs.git
synced 2026-07-17 02:16:43 +00:00
fix: route OpenRouter profiles through v1 API
This commit is contained in:
@@ -9,6 +9,11 @@ function ensureSupportedProtocol(parsed: URL): void {
|
||||
}
|
||||
}
|
||||
|
||||
function isOpenRouterHost(hostname: string): boolean {
|
||||
const normalized = hostname.toLowerCase();
|
||||
return normalized === 'openrouter.ai' || normalized.endsWith('.openrouter.ai');
|
||||
}
|
||||
|
||||
function buildResolvedUrl(baseUrl: string, suffix: string): string {
|
||||
const parsed = new URL(baseUrl);
|
||||
ensureSupportedProtocol(parsed);
|
||||
@@ -18,6 +23,11 @@ function buildResolvedUrl(baseUrl: string, suffix: string): string {
|
||||
return parsed.toString();
|
||||
}
|
||||
|
||||
if (isOpenRouterHost(parsed.hostname) && pathname.endsWith('/api')) {
|
||||
parsed.pathname = `${pathname}/v1${suffix}`;
|
||||
return parsed.toString();
|
||||
}
|
||||
|
||||
if (pathname.endsWith('/v1') || pathname.endsWith('/api')) {
|
||||
parsed.pathname = `${pathname}${suffix.startsWith('/') ? suffix : `/${suffix}`}`;
|
||||
return parsed.toString();
|
||||
|
||||
Reference in New Issue
Block a user