Uh oh!
There was an error while loading. Please reload this page.
Allow relative private API host for wallet portfolio - #612
Conversation
Uh oh!
There was an error while loading. Please reload this page.
📝 WalkthroughWalkthroughA validation check for Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
packages/wallets/src/modules/wallets/queries/get-vision-portfolio-query-options.ts (2)
217-221: LGTM! The relaxed check correctly enables relative API paths.The change from a falsy check to an explicit
undefined/nullcheck appropriately allows empty-string hosts for relative endpoints while still guarding against truly missing configuration.One optional consideration: whitespace-only strings (e.g.,
" ") would pass this check but produce malformed endpoints. You could leverage the existingnormalizeStringhelper for consistency:🔧 Optional: guard against whitespace-only strings
- if (CONFIG.privateApiHost === undefined || CONFIG.privateApiHost === null) {+ const host = typeof CONFIG.privateApiHost === "string" + ? CONFIG.privateApiHost.trim() + : CONFIG.privateApiHost;+ if (host === undefined || host === null) {Then use
hoston line 223. This ensures whitespace-only values are treated as empty strings rather than producing paths like" /wallet-api/portfolio-v2".
223-223: Consider normalizing trailing slashes in the host.If
CONFIG.privateApiHostever ends with a trailing slash (e.g.,https://api.example.com/), the endpoint would becomehttps://api.example.com//wallet-api/portfolio-v2with a double slash. Most servers handle this gracefully, but for robustness:🔧 Optional: strip trailing slash
- const endpoint = `${CONFIG.privateApiHost}/wallet-api/portfolio-v2`;+ const host = CONFIG.privateApiHost.replace(/\/+$/, "");+ const endpoint = `${host}/wallet-api/portfolio-v2`;
Motivation
privateApiHostvalue used for relative API paths.privateApiHostto an empty string on the main production domain to use relative endpoints, but the query treated that as missing and threw an error.ecency.com.Description
getVisionPortfolioQueryOptionsby changingif (!CONFIG.privateApiHost)to an explicitundefined/nullcheck.CONFIG.privateApiHostto be an empty string ('') so the endpoint can be built as a relative path (/wallet-api/portfolio-v2).packages/wallets/src/modules/wallets/queries/get-vision-portfolio-query-options.ts.Testing
privateApiHost.Codex Task
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.