-
Notifications
You must be signed in to change notification settings - Fork 2.8k
fix: respect custom OpenRouter URL for all API operations #8951
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Use configured openRouterBaseUrl in image generation instead of hardcoded URL - Dynamically include custom OpenRouter domain in CSP headers - Pass baseUrl to webview hooks for model endpoints fetching - Update useOpenRouterModelProviders hook to use custom baseUrl Fixes #8947
Review UpdateReviewed commit 24e00b6. No new changes since the last review at commit 1cad764. All previously identified issues have been resolved. Outstanding Issues
Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No issues found.
|
|
||
| // Get the OpenRouter base URL from configuration | ||
| const { apiConfiguration } = await this.getState() | ||
| const openRouterBaseUrl = apiConfiguration.openRouterBaseUrl || "https://openrouter.ai" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't the default base URL have /api/v1 in it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case only the origin part of the URL is used so there's no need to add the v1 part.
- Replace hardcoded 'https://openrouter.ai' fallback with derived domain from the same default base URL pattern used everywhere else - Extract domain from 'https://openrouter.ai/api/v1' for better consistency - Maintains backward compatibility and existing functionality - All tests still pass Fixes inconsistent OpenRouter base URL default in PR #8951
1cad764 to
24e00b6
Compare
Summary
This PR fixes an issue where custom OpenRouter URLs were not being fully respected throughout the application. When users configured a custom OpenRouter endpoint, some operations (model retrieval, cost calculations, CSP headers) would still use the hardcoded official OpenRouter URL.
Problem
As reported in #8947:
Solution
This PR ensures that all OpenRouter interactions respect the custom URL configuration:
Changes Made
Image Generation API - Use configured instead of hardcoded URL
CSP Headers - Dynamically include custom OpenRouter domain in Content Security Policy
Model Endpoints Fetching - Pass custom base URL to webview hooks
Testing
Fixes
Fixes #8947
Important
This PR ensures that all OpenRouter interactions respect the custom URL configuration, affecting image generation, CSP headers, and model endpoint fetching.
https://openrouter.ai/api/v1.openrouter.ts: UpdateOpenRouterHandlerto use custom URL for API requests.ClineProvider.ts: Modify CSP headers to include custom OpenRouter domain.ApiOptions.tsxanduseOpenRouterModelProviders.ts: Pass custom URL to hooks and functions for model provider fetching.This description was created by
for 1cad764663c6599fe7363f9242b380c32dd937bd. You can customize this summary. It will automatically update as commits are pushed.