chore: switch to sb.capgo.app for Supabase URLs#1770
Conversation
📝 WalkthroughWalkthroughThis pull request migrates Supabase URLs from the old endpoint (https://xvwzpoazmxkqosrdewyv.supabase.co) to a new self-hosted domain (https://sb.capgo.app) across configuration files, scripts, and services. One functional change modifies local environment detection logic. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~15 minutes Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
scripts/change_app_owner.ts (1)
43-44:⚠️ Potential issue | 🟡 MinorPre-existing bug: wrong error variable thrown.
This is not introduced by this PR, but there's a copy-paste error here —
error2is checked buterror1is thrown.🐛 Suggested fix
if (error2) - throw error1 + throw error2🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@scripts/change_app_owner.ts` around lines 43 - 44, The code checks the variable error2 but incorrectly throws error1; update the throw to rethrow the correct variable (throw error2) where the check if (error2) occurs so the actual detected error is propagated; locate the conditional that reads "if (error2)" and replace the thrown symbol to error2 (ensure any nearby error-handling logic around error1/error2 remains consistent).supabase/functions/_backend/utils/stripe.ts (1)
17-24:⚠️ Potential issue | 🟡 MinorDocumentation example doesn't match actual function behavior.
The comment shows
"https://sb.capgo.app" -> "sb.capgo.app", but the function at line 23 splits by//, then by., then by:, returning only the first segment. Forhttps://sb.capgo.app, the actual result would be"sb", not"sb.capgo.app".This could cause confusion for future maintainers. Consider correcting the example:
📝 Suggested documentation fix
// Extracts the Supabase project ID from SUPABASE_URL -// e.g., "https://sb.capgo.app" -> "sb.capgo.app" +// e.g., "https://sb.capgo.app" -> "sb" function getSupabaseProjectId(c: Context): string | null {🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@supabase/functions/_backend/utils/stripe.ts` around lines 17 - 24, The doc comment for getSupabaseProjectId is incorrect: the function returns only the first hostname segment (project id) not the full host; update the comment/example to match actual behavior (e.g., "https://sb.capgo.app" -> "sb") and add a short note that getSupabaseProjectId(c) splits SUPABASE_URL by '//' then '.' then ':' to return the first subdomain segment; keep the function logic unchanged and reference getSupabaseProjectId and supabaseUrl in the updated comment.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/services/supabase.ts`:
- Around line 22-24: Rename the misleading function isLocal(supaHost) to
isProduction(supaHost) (or isProdHost) and change its logic to return true only
when supaHost === 'https://sb.capgo.app' (invert current boolean). Then update
all call sites that currently use if (isLocal(supaHost)) to use the inverted
check if (!isProduction(supaHost)) — specifically replace calls in the PostHog
integration to call the new isProduction function and negate its result where
the old behavior expected non-production.
---
Outside diff comments:
In `@scripts/change_app_owner.ts`:
- Around line 43-44: The code checks the variable error2 but incorrectly throws
error1; update the throw to rethrow the correct variable (throw error2) where
the check if (error2) occurs so the actual detected error is propagated; locate
the conditional that reads "if (error2)" and replace the thrown symbol to error2
(ensure any nearby error-handling logic around error1/error2 remains
consistent).
In `@supabase/functions/_backend/utils/stripe.ts`:
- Around line 17-24: The doc comment for getSupabaseProjectId is incorrect: the
function returns only the first hostname segment (project id) not the full host;
update the comment/example to match actual behavior (e.g.,
"https://sb.capgo.app" -> "sb") and add a short note that
getSupabaseProjectId(c) splits SUPABASE_URL by '//' then '.' then ':' to return
the first subdomain segment; keep the function logic unchanged and reference
getSupabaseProjectId and supabaseUrl in the updated comment.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 1dcd757c-7f4e-4325-8902-5346b5ff535e
📒 Files selected for processing (10)
README.mdconfigs.jsonscripts/add_replicate.tsscripts/change_app_owner.tsscripts/create_missing_customers_for_orgs.tsscripts/del_replicate.tsscripts/fix_app_stats_day_1.mjssrc/services/supabase.tssupabase/functions/_backend/utils/stripe.tssupabase/functions/_backend/utils/supaMetric.ts
| export function isLocal(supaHost: string) { | ||
| return supaHost !== 'https://xvwzpoazmxkqosrdewyv-all.supabase.co' && supaHost !== 'https://xvwzpoazmxkqosrdewyv.supabase.co' | ||
| return supaHost !== 'https://sb.capgo.app' | ||
| } |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Description: Check how isLocal() is used to understand the impact of this logic change
# Find all usages of isLocal function
echo "=== Usages of isLocal() ==="
rg -n -C3 'isLocal\(' --type=ts --type=vue
# Check if there are any other Supabase URLs defined in environment files or configs
echo -e "\n=== Supabase URLs in config/env files ==="
rg -n 'SUPABASE_URL|supaHost' --type-add 'env:*.env*' -g '*.env*' -g '*.json' -g '*.ts'Repository: Cap-go/capgo
Length of output: 6847
🏁 Script executed:
#!/bin/bash
# Find environment configuration files and VITE_SUPABASE_URL values
echo "=== Looking for .env files and vite config ==="
fd -e '.env*' -o -name 'vite.config.*' -o -name '.env*'
echo -e "\n=== Content of .env files ==="
cat .env 2>/dev/null || echo "No .env file"
cat .env.local 2>/dev/null || echo "No .env.local file"
cat .env.example 2>/dev/null || echo "No .env.example file"
echo -e "\n=== Checking for VITE_ environment variables in config ==="
rg 'VITE_SUPABASE_URL|VITE_APP_URL' --type=ts --type=js -A2 -B2 2>/dev/null || trueRepository: Cap-go/capgo
Length of output: 3108
🏁 Script executed:
#!/bin/bash
# Check for any recent changes or previous Supabase URLs in the codebase
echo "=== Checking posthog.ts to understand isLocal usage context ==="
cat -n src/services/posthog.ts | head -30
echo -e "\n=== Check supabase.ts complete ==="
cat -n src/services/supabase.tsRepository: Cap-go/capgo
Length of output: 23856
Function name isLocal() is misleading—it checks for production, not local development.
The logic is intentional: isLocal() returns false only for https://sb.capgo.app (production), disabling PostHog analytics everywhere else. However, the function name suggests it checks for local development (localhost/127.0.0.1), when it actually checks "is this the production host?"
If other valid production or staging URLs exist, they would be treated as non-production. Consider renaming to isProduction() or isProdHost() for clarity:
-export function isLocal(supaHost: string) {
- return supaHost !== 'https://sb.capgo.app'
+export function isProduction(supaHost: string) {
+ return supaHost === 'https://sb.capgo.app'
}Then update usages in src/services/posthog.ts (lines 5, 58, 69, 82) from if (isLocal(supaHost)) to if (!isProduction(supaHost)).
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/services/supabase.ts` around lines 22 - 24, Rename the misleading
function isLocal(supaHost) to isProduction(supaHost) (or isProdHost) and change
its logic to return true only when supaHost === 'https://sb.capgo.app' (invert
current boolean). Then update all call sites that currently use if
(isLocal(supaHost)) to use the inverted check if (!isProduction(supaHost)) —
specifically replace calls in the PostHog integration to call the new
isProduction function and negate its result where the old behavior expected
non-production.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9003d24daa
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| "supa_url": { | ||
| "prod": "https://xvwzpoazmxkqosrdewyv.supabase.co", | ||
| "preprod": "https://xvwzpoazmxkqosrdewyv.supabase.co", | ||
| "prod": "https://sb.capgo.app", |
There was a problem hiding this comment.
Preserve project ref when switching to custom Supabase URL
Updating supa_url.prod to https://sb.capgo.app breaks code paths that derive a Supabase project ref from the URL host prefix (split('//')[1].split('.')[0]): that now yields sb instead of the real ref (xvwzpoazmxkqosrdewyv, still used in package.json deploy scripts). I checked scripts/getTypes.mjs (builds --project-id=${supaId}) and .github/workflows/bump_version.yml (BRANCH=main bun types), plus supabase/functions/_backend/utils/supabase-management.ts (/v1/projects/${projectRef}), and they would target project sb once this URL is used there. This will cause type generation and SSO management API calls to fail unless project ref is configured independently from the public Supabase URL.
Useful? React with 👍 / 👎.



Summary (AI generated)
xvwzpoazmxkqosrdewyv.supabase.cowithsb.capgo.appinconfigs.json,README.md, and Supabase/CLI scripts.src/services/supabase.tshost-check logic and refreshed related backend utility examples.Motivation (AI generated)
Business Impact (AI generated)
Test Plan (AI generated)
bun lintbun lint:backendbunx eslint --no-ignore scripts/add_replicate.ts scripts/change_app_owner.ts scripts/create_missing_customers_for_orgs.ts scripts/del_replicate.ts scripts/fix_app_stats_day_1.mjsgit diff origin/main...Generated with AI
Summary by CodeRabbit