Skip to content

chore: switch to sb.capgo.app for Supabase URLs#1770

Merged
riderx merged 1 commit into
mainfrom
riderx/fix-supabase-domain
Mar 10, 2026
Merged

chore: switch to sb.capgo.app for Supabase URLs#1770
riderx merged 1 commit into
mainfrom
riderx/fix-supabase-domain

Conversation

@riderx
Copy link
Copy Markdown
Member

@riderx riderx commented Mar 10, 2026

Summary (AI generated)

  • Replaced legacy Supabase host references xvwzpoazmxkqosrdewyv.supabase.co with sb.capgo.app in configs.json, README.md, and Supabase/CLI scripts.
  • Updated src/services/supabase.ts host-check logic and refreshed related backend utility examples.

Motivation (AI generated)

  • Standardizes active Supabase endpoint usage to the new domain to avoid stale configuration and simplify deployment/debugging.

Business Impact (AI generated)

  • Reduces operational risk from mixed Supabase domains in runtime configuration, scripts, and docs.

Test Plan (AI generated)

  • bun lint
  • bun lint:backend
  • bunx 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.mjs
  • git diff origin/main...

Generated with AI

Summary by CodeRabbit

  • Chores
    • Updated Supabase infrastructure endpoints across production and pre-production environments with new configuration values.
    • Refreshed backend configuration files, service initialization scripts, and client URLs to reflect the infrastructure changes.
    • Updated internal service documentation and utility function references to align with the new endpoints.
    • Ensured system-wide configuration consistency.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 10, 2026

📝 Walkthrough

Walkthrough

This 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

Cohort / File(s) Summary
Configuration Files
README.md, configs.json
Updated Supabase URL references from old endpoint to https://sb.capgo.app in environment configuration documentation and deployment config.
Build and Utility Scripts
scripts/add_replicate.ts, scripts/change_app_owner.ts, scripts/del_replicate.ts, scripts/fix_app_stats_day_1.mjs
Updated hardcoded Supabase client URL constant from old endpoint to https://sb.capgo.app. No control flow changes.
External Integration Script
scripts/create_missing_customers_for_orgs.ts
Repointed external trigger call URL to https://sb.capgo.app and added missing newline at end of file.
Supabase Service Logic
src/services/supabase.ts
Changed isLocal function logic to exclude only https://sb.capgo.app instead of two previously-excluded Supabase hosts, affecting local environment detection.
Backend Utilities
supabase/functions/_backend/utils/stripe.ts, supabase/functions/_backend/utils/suMetric.ts
Updated example URL in JSDoc comment and Prometheus metric reference from old Supabase domain to new domain (db.sb.capgo.app). No functional changes.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~15 minutes

Poem

🐰 A hop through URLs, from old to new,
Where capgo.app is now our destination true,
Scripts and configs dance in their place,
Supabase endpoints set a faster pace!
🌟

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 37.50% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive The description includes a summary and motivation but lacks the required Test plan, Screenshots, and Checklist sections from the template, though test execution is mentioned as completed. Add the missing template sections: formal Test Plan section with reproduction steps, Screenshots section (if applicable), and properly filled Checklist with checkboxes marked as requested.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The pull request title clearly and concisely describes the main change: switching Supabase URLs from the old domain to sb.capgo.app, which is the primary objective of this changeset.

✏️ 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 riderx/fix-supabase-domain

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

Copy link
Copy Markdown
Contributor

@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.

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 | 🟡 Minor

Pre-existing bug: wrong error variable thrown.

This is not introduced by this PR, but there's a copy-paste error here — error2 is checked but error1 is 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 | 🟡 Minor

Documentation 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. For https://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

📥 Commits

Reviewing files that changed from the base of the PR and between 3d34cfb and 9003d24.

📒 Files selected for processing (10)
  • README.md
  • configs.json
  • 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.mjs
  • src/services/supabase.ts
  • supabase/functions/_backend/utils/stripe.ts
  • supabase/functions/_backend/utils/supaMetric.ts

Comment thread src/services/supabase.ts
Comment on lines 22 to 24
export function isLocal(supaHost: string) {
return supaHost !== 'https://xvwzpoazmxkqosrdewyv-all.supabase.co' && supaHost !== 'https://xvwzpoazmxkqosrdewyv.supabase.co'
return supaHost !== 'https://sb.capgo.app'
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 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 || true

Repository: 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.ts

Repository: 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.

@sonarqubecloud
Copy link
Copy Markdown

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 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".

Comment thread configs.json
"supa_url": {
"prod": "https://xvwzpoazmxkqosrdewyv.supabase.co",
"preprod": "https://xvwzpoazmxkqosrdewyv.supabase.co",
"prod": "https://sb.capgo.app",
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge 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 👍 / 👎.

@riderx riderx merged commit 4cc9a83 into main Mar 10, 2026
15 checks passed
@riderx riderx deleted the riderx/fix-supabase-domain branch March 10, 2026 14:50
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