fix(desktop): route subscription/payment endpoints to Python backend (fixes #6065)#6068
fix(desktop): route subscription/payment endpoints to Python backend (fixes #6065)#6068
Conversation
…ixes #6065) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Greptile SummaryThis PR fixes a 404 error on the Plan & Usage settings page by routing three subscription/payment API calls ( Confidence Score: 4/5Safe 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 No files require special attention beyond the noted style concern in Important Files Changed
Sequence DiagramsequenceDiagram
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 ✓
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/" } |
There was a problem hiding this comment.
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:
| 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/" | |
| } |
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
pythonBaseURLproperty pointing tohttps://api.omi.me/customBaseURLparameter topost()methodgetUserSubscription,createCheckoutSession, andcreateCustomerPortalSessionto Python backendImpact
Plan & Usage settings page now loads correctly instead of showing "Failed to load plan information".
Fixes #6065