Skip to content

fix(desktop): route subscription/payment endpoints to Python backend (fixes #6065)#6068

Open
kodjima33 wants to merge 1 commit intomainfrom
fix/issue-6065
Open

fix(desktop): route subscription/payment endpoints to Python backend (fixes #6065)#6068
kodjima33 wants to merge 1 commit intomainfrom
fix/issue-6065

Conversation

@kodjima33
Copy link
Copy Markdown
Collaborator

Summary

Routes subscription and payment API calls to the Python backend (api.omi.me) instead of the Rust desktop backend where they return 404.

Changes

  • Add pythonBaseURL property pointing to https://api.omi.me/
  • Add customBaseURL parameter to post() method
  • Route getUserSubscription, createCheckoutSession, and createCustomerPortalSession to Python backend

Impact

Plan & Usage settings page now loads correctly instead of showing "Failed to load plan information".

Fixes #6065

…ixes #6065)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 26, 2026

Greptile Summary

This PR fixes a 404 error on the Plan & Usage settings page by routing three subscription/payment API calls (getUserSubscription, createCheckoutSession, createCustomerPortalSession) to the Python backend (https://api.omi.me/) instead of the Rust desktop backend, which does not expose these endpoints.\n\nChanges:\n- Adds a pythonBaseURL computed property hard-coded to https://api.omi.me/\n- Adds customBaseURL: String? = nil to the no-body post() overload (the other overloads already supported it)\n- Updates the three payment/subscription methods to pass pythonBaseURL via customBaseURL\n\nIssues found:\n- pythonBaseURL is hard-coded and cannot be overridden via environment variable, unlike baseURL which reads from OMI_API_URL. This makes it impossible to test subscription flows against a staging Python backend without modifying source code. Adding an OMI_PYTHON_API_URL env-var fallback (mirroring baseURL) would maintain consistency and improve developer flexibility.

Confidence Score: 4/5

Safe to merge — fixes a real user-facing 404 with a minimal, correct change; one non-blocking style concern remains.

The core fix is correct and well-targeted: the three affected methods now correctly resolve to the Python backend. URL construction is safe (the hard-coded URL is valid and ends with "/"). The only concern is pythonBaseURL being hard-coded without an env-var override, which is a developer-experience issue rather than a production correctness or security problem. This does not block merging.

No files require special attention beyond the noted style concern in desktop/Desktop/Sources/APIClient.swift.

Important Files Changed

Filename Overview
desktop/Desktop/Sources/APIClient.swift Adds pythonBaseURL (hardcoded) and customBaseURL to the no-body post() overload; routes subscription and payment endpoints to api.omi.me — fix is correct, but the Python URL lacks env-var override support.

Sequence Diagram

sequenceDiagram
    participant App as Desktop App
    participant Rust as Rust Backend (OMI_API_URL)
    participant Python as Python Backend (api.omi.me)

    Note over App,Python: Before this PR — all calls went to Rust backend
    App->>Rust: GET v1/users/me/subscription → 404
    App->>Rust: POST v1/payments/checkout-session → 404
    App->>Rust: POST v1/payments/customer-portal → 404

    Note over App,Python: After this PR — payment/subscription calls routed correctly
    App->>Python: GET v1/users/me/subscription (customBaseURL=pythonBaseURL)
    Python-->>App: UserSubscriptionResponse ✓
    App->>Python: POST v1/payments/checkout-session (customBaseURL=pythonBaseURL)
    Python-->>App: CheckoutSessionResponse ✓
    App->>Python: POST v1/payments/customer-portal (customBaseURL=pythonBaseURL)
    Python-->>App: CustomerPortalResponse ✓
    App->>Rust: All other endpoints (baseURL from OMI_API_URL)
    Rust-->>App: Responses ✓
Loading

Reviews (1): Last reviewed commit: "fix(desktop): route subscription/payment..." | Re-trigger Greptile

}

// Python backend URL — subscription and payment endpoints only exist here
var pythonBaseURL: String { "https://api.omi.me/" }
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 pythonBaseURL is hardcoded, unlike baseURL

baseURL reads from the OMI_API_URL environment variable, enabling developers to point the Rust backend at a staging or local instance. pythonBaseURL has no equivalent override mechanism, so anyone who needs to test subscription/payment flows against a staging Python backend can't do so without modifying source code.

Consider reading from an environment variable with a production fallback, mirroring the pattern already used for baseURL:

Suggested change
var pythonBaseURL: String { "https://api.omi.me/" }
var pythonBaseURL: String {
if let cString = getenv("OMI_PYTHON_API_URL"), let url = String(validatingUTF8: cString), !url.isEmpty {
return url.hasSuffix("/") ? url : url + "/"
}
if let envURL = ProcessInfo.processInfo.environment["OMI_PYTHON_API_URL"], !envURL.isEmpty {
return envURL.hasSuffix("/") ? envURL : envURL + "/"
}
return "https://api.omi.me/"
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Desktop: subscription endpoints hit Rust backend (404) instead of Python backend

1 participant