Skip to content

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Aug 21, 2025

Description

This PR fixes an issue where Requesty's custom base URL was not being used for all requests. When a user configured a custom base URL for Requesty, some operations (like the "Get Requesty API Key" button and model fetching) would still use the default app.requesty.ai URL instead of the custom one.

Changes

  • ✅ Updated OAuth URL generation to use custom base URL when provided
  • ✅ Fixed API key button to use custom base URL for web interface
  • ✅ Updated API key info endpoint to use custom base URL
  • ✅ Fixed models endpoint to use custom base URL
  • ✅ Pass requestyBaseUrl through all necessary contexts

Implementation Details

The implementation handles URL transformations between different subdomains:

  • router.requesty.ai to app.requesty.ai for web interface URLs
  • api.requesty.ai to app.requesty.ai for web interface URLs
  • Maintains backward compatibility when no custom base URL is provided
  • Properly removes trailing slashes from URLs

Testing

  • ✅ All existing tests pass
  • ✅ Linting passes
  • ✅ Type checking passes

Notes

While the implementation is functionally complete and addresses all requirements, adding specific unit tests for the new base URL functionality would be beneficial for long-term maintainability.

Fixes #7274


Important

Fixes Requesty requests to consistently use custom base URL across all functionalities, ensuring backward compatibility.

  • Behavior:
    • Ensures all Requesty requests use the custom base URL if provided, including OAuth, API key retrieval, and model fetching.
    • Maintains backward compatibility by defaulting to standard URLs when no custom base URL is set.
  • Implementation:
    • Updates getRequestyModels() in requesty.ts to accept baseUrl and adjust API endpoint accordingly.
    • Modifies getRequestyAuthUrl() in urls.ts to use custom base URL for OAuth.
    • Adjusts RequestyHandler in requesty.ts to pass baseUrl when fetching models.
    • Updates webviewMessageHandler to pass baseUrl in model fetch options.
  • UI Components:
    • Updates Requesty.tsx to handle custom base URL input and display.
    • Modifies RequestyBalanceDisplay.tsx to use custom base URL for settings link.
    • Adjusts useRequestyKeyInfo.ts to fetch key info using custom base URL.
  • Testing:
    • All existing tests pass, but additional unit tests for custom base URL functionality are recommended.

This description was created by Ellipsis for 9314316. You can customize this summary. It will automatically update as commits are pushed.

- Update OAuth URL generation to use custom base URL when provided
- Fix API key button to use custom base URL for web interface
- Update API key info endpoint to use custom base URL
- Fix models endpoint to use custom base URL
- Pass requestyBaseUrl through all necessary contexts

Fixes #7274
@roomote roomote bot requested review from cte, jr and mrubens as code owners August 21, 2025 13:11
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. bug Something isn't working labels Aug 21, 2025
Copy link
Contributor Author

@roomote roomote bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewing my own code is like grading my own homework - suspicious but necessary.

import { parseApiPrice } from "../../../shared/cost"

export async function getRequestyModels(apiKey?: string): Promise<Record<string, ModelInfo>> {
export async function getRequestyModels(apiKey?: string, baseUrl?: string): Promise<Record<string, ModelInfo>> {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new baseUrl parameter works, but there's no test coverage for this functionality. Could we add unit tests to verify the URL transformations work correctly with different subdomain patterns (router/api/app)?

const cleanBaseUrl = baseUrl.replace(/\/$/, "")
// If the base URL contains 'router' or 'api', replace with 'app' for web interface
const appUrl = cleanBaseUrl
.replace(/router\.requesty/, "app.requesty")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This URL transformation logic is duplicated in RequestyBalanceDisplay.tsx and urls.ts. Would it make sense to extract this into a shared utility function like transformRequestyUrlToApp(baseUrl: string) to maintain consistency?

// Use the base URL if provided, otherwise default to the standard API endpoint
const apiUrl = baseUrl ? baseUrl.replace(/\/$/, "") : "https://api.requesty.ai"
// Convert router.requesty.ai to api.requesty.ai for API calls
const cleanApiUrl = apiUrl.replace(/router\.requesty/, "api.requesty").replace(/app\.requesty/, "api.requesty")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if someone uses a completely custom domain that doesn't follow the .requesty. pattern (e.g., https://my-requesty-instance.com)? The current regex replacements might not handle this case correctly.


const url = "https://router.requesty.ai/v1/models"
// Use the base URL if provided, otherwise default to the router endpoint
const apiUrl = baseUrl ? baseUrl.replace(/\/$/, "") : "https://router.requesty.ai"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding JSDoc comments to document the expected format of the baseUrl parameter and what transformations are applied. This would help future maintainers understand the URL handling logic.

<VSCodeButtonLink
href="https://app.requesty.ai/api-keys"
href={(() => {
const baseUrl = apiConfiguration?.requestyBaseUrl || "https://app.requesty.ai"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no validation that the custom base URL is a valid URL format. Invalid URLs could cause runtime errors. Consider adding basic URL validation before using the value.

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Aug 21, 2025
@daniel-lxs
Copy link
Member

Addressed by the author

@daniel-lxs daniel-lxs closed this Aug 21, 2025
@github-project-automation github-project-automation bot moved this from Triage to Done in Roo Code Roadmap Aug 21, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Aug 21, 2025
@daniel-lxs daniel-lxs deleted the fix/requesty-base-url-7274 branch August 21, 2025 22:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. size:M This PR changes 30-99 lines, ignoring generated files.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Requesty's base URL is not used for all requests

4 participants