Skip to content

ui: add proxy support for jupiter client#2121

Open
cha-kos wants to merge 1 commit intomasterfrom
chakos/fe-4083-handle-jupiter-api-key-enforcement-by-january-31
Open

ui: add proxy support for jupiter client#2121
cha-kos wants to merge 1 commit intomasterfrom
chakos/fe-4083-handle-jupiter-api-key-enforcement-by-january-31

Conversation

@cha-kos
Copy link
Collaborator

@cha-kos cha-kos commented Feb 25, 2026

Summary by CodeRabbit

  • New Features
    • Added proxy support to the Jupiter client, allowing API requests to be routed through a configured proxy server for enhanced network flexibility and control.

@coderabbitai
Copy link

coderabbitai bot commented Feb 25, 2026

📝 Walkthrough

Walkthrough

Introduces proxy support to JupiterClient by adding an optional proxyUrl parameter. When configured, API requests route through the proxy URL instead of direct calls, with API key header generation conditionally skipped. A new getBaseUrl() helper method determines the appropriate base URL based on proxy presence.

Changes

Cohort / File(s) Summary
Proxy Support Implementation
sdk/src/jupiter/jupiterClient.ts
Added optional proxyUrl field and constructor parameter. New getBaseUrl() method selects between proxy and original URL. Conditional logic skips API key header when proxy is active. Quote and swap request endpoints updated to use base URL with conditional API version handling.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A rabbit hops through proxy gates so fine,
No direct paths, just routing divine,
Auth headers skip when proxy's the way,
Bouncing requests through URLs each day!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'ui: add proxy support for jupiter client' accurately summarizes the main change: introducing proxy support to the JupiterClient with new proxyUrl parameter and getBaseUrl() method.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch chakos/fe-4083-handle-jupiter-api-key-enforcement-by-january-31

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
sdk/src/jupiter/jupiterClient.ts (2)

342-347: Unnecessary fetchOptions conditional — simplify to always pass headers.

fetch accepts an empty headers object without issue, so the guard on line 342 adds complexity with no benefit. It also creates an inconsistency with getSwap, which always passes headers directly.

♻️ Proposed simplification
-    const fetchOptions =
-        Object.keys(headers).length > 0 ? { headers } : {};
     const quote = await (
         await fetch(
             `${baseUrl}${apiVersionParam}/quote?${params.toString()}`,
-            fetchOptions
+            { headers }
         )
     ).json();
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@sdk/src/jupiter/jupiterClient.ts` around lines 342 - 347, The fetchOptions
conditional is unnecessary; remove the fetchOptions variable and always pass the
headers directly to fetch (i.e., replace usage of fetchOptions with { headers })
so the call in the quote retrieval uses
fetch(`${baseUrl}${apiVersionParam}/quote?${params.toString()}`, { headers });
also update any related local references in jupiterClient.ts and keep consistent
with getSwap which already passes headers directly.

337-340: Extract the duplicated apiVersionParam logic into a private helper.

The identical expression for apiVersionParam is copy-pasted verbatim in both getQuote (lines 337-340) and getSwap (lines 373-376). Extract it to keep the logic in one place.

♻️ Proposed refactor — add a `getApiVersionParam()` helper
+ private getApiVersionParam(): string {
+     return !this.proxyUrl &&
+         (this.url === RECOMMENDED_JUPITER_API || this.url === LEGACY_JUPITER_API)
+         ? RECOMMENDED_JUPITER_API_VERSION
+         : '';
+ }

Then replace both sites:

-    const apiVersionParam =
-        !this.proxyUrl && (this.url === RECOMMENDED_JUPITER_API || this.url === LEGACY_JUPITER_API)
-            ? RECOMMENDED_JUPITER_API_VERSION
-            : '';
+    const apiVersionParam = this.getApiVersionParam();

Also applies to: 373-376

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@sdk/src/jupiter/jupiterClient.ts` around lines 337 - 340, The duplicated
computation of apiVersionParam used in getQuote and getSwap should be extracted
into a single private helper: add a private getApiVersionParam() method that
returns the current expression (!this.proxyUrl && (this.url ===
RECOMMENDED_JUPITER_API || this.url === LEGACY_JUPITER_API) ?
RECOMMENDED_JUPITER_API_VERSION : ''), then replace the inline apiVersionParam
assignments in getQuote and getSwap with calls to this.getApiVersionParam();
ensure the helper is used wherever that same logic appears to avoid future
divergence.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@sdk/src/jupiter/jupiterClient.ts`:
- Around line 342-347: The fetchOptions conditional is unnecessary; remove the
fetchOptions variable and always pass the headers directly to fetch (i.e.,
replace usage of fetchOptions with { headers }) so the call in the quote
retrieval uses fetch(`${baseUrl}${apiVersionParam}/quote?${params.toString()}`,
{ headers }); also update any related local references in jupiterClient.ts and
keep consistent with getSwap which already passes headers directly.
- Around line 337-340: The duplicated computation of apiVersionParam used in
getQuote and getSwap should be extracted into a single private helper: add a
private getApiVersionParam() method that returns the current expression
(!this.proxyUrl && (this.url === RECOMMENDED_JUPITER_API || this.url ===
LEGACY_JUPITER_API) ? RECOMMENDED_JUPITER_API_VERSION : ''), then replace the
inline apiVersionParam assignments in getQuote and getSwap with calls to
this.getApiVersionParam(); ensure the helper is used wherever that same logic
appears to avoid future divergence.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1cf0e19 and ad10b94.

📒 Files selected for processing (1)
  • sdk/src/jupiter/jupiterClient.ts

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.

1 participant