Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
WalkthroughIntroduces environment-specific API base URL configuration for campaign sync endpoints. A new Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Suggested reviewers
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
🧪 Generate unit tests (beta)
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: 1
🤖 Fix all issues with AI agents
In `@src/common/api/indexer/sync.ts`:
- Around line 3-7: Replace the hardcoded campaigns URL by reading a new env var
(e.g., NEXT_PUBLIC_CAMPAIGNS_API_URL) instead of "https://dev.potlock.io" in
CAMPAIGNS_SYNC_API_BASE_URL, and update the top comment about SYNC_API_BASE_URL
to accurately reflect INDEXER_API_ENDPOINT_URL being environment-dependent; if
routing campaigns to dev is intentional and temporary, add a clear TEMPORARY
comment on CAMPAIGNS_SYNC_API_BASE_URL (e.g., "// TEMPORARY: campaigns only on
dev backend until migration to prod") so future maintainers know to revisit the
decision.
| // Campaigns only exist on dev backend, everything else is on prod | ||
| const SYNC_API_BASE_URL = INDEXER_API_ENDPOINT_URL; | ||
|
|
||
| const CAMPAIGNS_SYNC_API_BASE_URL = | ||
| process.env.NEXT_PUBLIC_ENV === "test" ? INDEXER_API_ENDPOINT_URL : "https://dev.potlock.io"; |
There was a problem hiding this comment.
Hardcoded dev URL used for production campaign traffic is risky.
Two concerns:
-
Hardcoded URL:
"https://dev.potlock.io"should be extracted to an environment variable (e.g.,NEXT_PUBLIC_CAMPAIGNS_API_URL) rather than hardcoded. This makes it easier to rotate endpoints and avoids embedding infrastructure details in application code. -
Production → dev backend: In non-test environments (including production), campaign sync calls will hit the dev server. If this is intentional and temporary, consider adding a more explicit comment (e.g.,
// TEMPORARY: campaigns are only deployed to dev backend until migration to prod) so future maintainers understand the intent and know to revisit it.
Also, the comment on line 3 ("everything else is on prod") is misleading since SYNC_API_BASE_URL resolves to INDEXER_API_ENDPOINT_URL, which is environment-dependent—not always prod.
Suggested improvement
-// Campaigns only exist on dev backend, everything else is on prod
-const SYNC_API_BASE_URL = INDEXER_API_ENDPOINT_URL;
-
-const CAMPAIGNS_SYNC_API_BASE_URL =
- process.env.NEXT_PUBLIC_ENV === "test" ? INDEXER_API_ENDPOINT_URL : "https://dev.potlock.io";
+// Base URL for most sync endpoints (environment-aware)
+const SYNC_API_BASE_URL = INDEXER_API_ENDPOINT_URL;
+
+// TEMPORARY: Campaigns are only available on the dev backend until migrated to prod.
+// In test, use the standard indexer; otherwise, point to the dev backend.
+const CAMPAIGNS_SYNC_API_BASE_URL =
+ process.env.NEXT_PUBLIC_ENV === "test"
+ ? INDEXER_API_ENDPOINT_URL
+ : (process.env.NEXT_PUBLIC_CAMPAIGNS_API_URL ?? "https://dev.potlock.io");🤖 Prompt for AI Agents
In `@src/common/api/indexer/sync.ts` around lines 3 - 7, Replace the hardcoded
campaigns URL by reading a new env var (e.g., NEXT_PUBLIC_CAMPAIGNS_API_URL)
instead of "https://dev.potlock.io" in CAMPAIGNS_SYNC_API_BASE_URL, and update
the top comment about SYNC_API_BASE_URL to accurately reflect
INDEXER_API_ENDPOINT_URL being environment-dependent; if routing campaigns to
dev is intentional and temporary, add a clear TEMPORARY comment on
CAMPAIGNS_SYNC_API_BASE_URL (e.g., "// TEMPORARY: campaigns only on dev backend
until migration to prod") so future maintainers know to revisit the decision.
Summary by CodeRabbit