Skip to content

chore(api): remove legacy Vercel electric proxy#3637

Merged
saddlepaddle merged 1 commit into
mainfrom
remove-old-electric
Apr 22, 2026
Merged

chore(api): remove legacy Vercel electric proxy#3637
saddlepaddle merged 1 commit into
mainfrom
remove-old-electric

Conversation

@saddlepaddle
Copy link
Copy Markdown
Collaborator

@saddlepaddle saddlepaddle commented Apr 22, 2026

Summary

  • Drops the unused /api/electric/[...path] route from the Vercel api, along with its env vars (ELECTRIC_URL, ELECTRIC_SECRET, ELECTRIC_SOURCE_ID, ELECTRIC_SOURCE_SECRET), @electric-sql/client dep, and Electric-specific CORS headers.
  • Bumps MINIMUM_DESKTOP_VERSION from 0.0.481.5.0 (first release after 2026-04-10) so any client old enough to still be hitting this proxy is forced to update first.
  • Removes ELECTRIC_URL/ELECTRIC_SECRET passthroughs from the Vercel api deploy steps in deploy-production.yml and deploy-preview.yml.

The Cloudflare worker (apps/electric-proxy), the Fly-hosted Electric instance, and NEXT_PUBLIC_ELECTRIC_URL used by desktop/mobile to reach the worker are all untouched.

Test plan

  • Preview deploy succeeds without ELECTRIC_* env vars
  • Desktop on < 1.5.0 sees the update-required screen on launch
  • Desktop on >= 1.5.0 boots and syncs via the Cloudflare worker as before

Summary by cubic

Removed the legacy Vercel /api/electric/* proxy and raised the minimum desktop version to 1.5.0 so older clients update before the endpoint is removed; the Cloudflare worker proxy and Fly-hosted Electric remain.

  • Refactors

    • Deleted apps/api/src/app/api/electric/[...path]/*.
    • Removed ELECTRIC_* server envs and deploy workflow passthroughs; trimmed Electric-specific CORS headers.
    • Dropped @electric-sql/client from apps/api/package.json and lockfile.
  • Migration

    • Desktop must be >= 1.5.0; older versions see the update-required screen.
    • Vercel deploys no longer need ELECTRIC_URL/ELECTRIC_SECRET.

Written for commit c42e268. Summary will update on new commits.

Summary by CodeRabbit

  • Bug Fixes

    • Minimum desktop application version requirement raised to 1.5.0
  • Chores

    • Removed Electric SQL integration and associated package dependency
    • Cleaned up Electric-related environment configuration and removed passing those values to deployments
    • Simplified API proxy CORS headers and reduced exposed sync-related headers

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 22, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 83f74d5f-c14b-4f78-a1d5-7d554360ac25

📥 Commits

Reviewing files that changed from the base of the PR and between 490d754 and c42e268.

⛔ Files ignored due to path filters (1)
  • bun.lock is excluded by !**/*.lock
📒 Files selected for processing (8)
  • .github/workflows/deploy-preview.yml
  • .github/workflows/deploy-production.yml
  • apps/api/package.json
  • apps/api/src/app/api/desktop/version/route.ts
  • apps/api/src/app/api/electric/[...path]/route.ts
  • apps/api/src/app/api/electric/[...path]/utils.ts
  • apps/api/src/env.ts
  • apps/api/src/proxy.ts
💤 Files with no reviewable changes (6)
  • apps/api/package.json
  • .github/workflows/deploy-preview.yml
  • apps/api/src/app/api/electric/[...path]/utils.ts
  • .github/workflows/deploy-production.yml
  • apps/api/src/env.ts
  • apps/api/src/app/api/electric/[...path]/route.ts
✅ Files skipped from review due to trivial changes (2)
  • apps/api/src/app/api/desktop/version/route.ts
  • apps/api/src/proxy.ts

📝 Walkthrough

Walkthrough

Removed Electric sync integration: proxy route and utilities, related env vars and dependency, workflow secrets for deployments, and Electric-specific CORS headers; also bumped minimum desktop version to 1.5.0.

Changes

Cohort / File(s) Summary
Workflow Configuration
​.github/workflows/deploy-preview.yml, ​.github/workflows/deploy-production.yml
Removed passing of ELECTRIC_URL and ELECTRIC_SECRET to Vercel deployment jobs/commands.
Electric API Route Removal
apps/api/src/app/api/electric/[...path]/route.ts, apps/api/src/app/api/electric/[...path]/utils.ts
Deleted Electric proxy GET route and its buildWhereClause utilities (authorization, query building, and proxying logic removed).
Environment & Dependency Cleanup
apps/api/src/env.ts, apps/api/package.json
Removed ELECTRIC_* environment declarations from server env schema and removed @electric-sql/client dependency.
API Surface & CORS
apps/api/src/app/api/desktop/version/route.ts, apps/api/src/proxy.ts
Updated MINIMUM_DESKTOP_VERSION to 1.5.0; removed X-Electric-Backend from allowed CORS request headers and removed Electric sync-related exposed response headers.

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant API
  participant DB
  participant Electric
  Client->>API: GET /api/electric/...
  alt Before change
    API->>DB: buildWhereClause / auth checks
    API->>Electric: proxy request (includes ELECTRIC_* env & protocol params)
    Electric-->>API: proxied response (sync headers)
    API-->>Client: proxied response
  else After change
    API-->>Client: 404/route removed or direct handling (no proxy)
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐰 I hopped through code, then cleared the tracks,
Old electric wires are packed in sacks.
Routes and secrets tucked away,
Desktop asks for 1.5 today —
A little hop, a joyful bounce-back!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: removal of the legacy Vercel Electric proxy route and related infrastructure.
Description check ✅ Passed The description covers key changes, includes a test plan, and provides context about unchanged components; however, it deviates from the repository template structure.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch remove-old-electric

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.

❤️ Share

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

@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented Apr 22, 2026

Greptile Summary

This PR removes the legacy Vercel-hosted Electric sync proxy (/api/electric/[...path]) and all associated infrastructure — env vars, CORS headers, the @electric-sql/client dependency, and CI passthrough secrets — replacing the migration gate with a MINIMUM_DESKTOP_VERSION bump (0.0.481.5.0) that forces any client old enough to still be hitting this proxy to update before it can connect.

Key changes:

  • Deleted apps/api/src/app/api/electric/[...path]/route.ts and utils.ts — the authenticated proxy with JWT/session auth, org membership enforcement, table-level where-clause filtering, and column redaction is fully gone.
  • Removed ELECTRIC_URL, ELECTRIC_SECRET, ELECTRIC_SOURCE_ID, and ELECTRIC_SOURCE_SECRET from env.ts; the server will no longer fail to start if these vars are absent.
  • Stripped X-Electric-Backend from Access-Control-Allow-Headers and all six electric-* response headers from Access-Control-Expose-Headers in proxy.ts.
  • Dropped ELECTRIC_URL/ELECTRIC_SECRET from both deploy-preview.yml and deploy-production.yml CI steps.
  • The Cloudflare worker (apps/electric-proxy), the Fly-hosted Electric instance, and NEXT_PUBLIC_ELECTRIC_URL are intentionally untouched.
  • The MINIMUM_DESKTOP_VERSION jump is intentionally aggressive: any client between 0.0.48 and 1.5.0 will see the update-required screen. This is the designed migration forcing function.

Confidence Score: 5/5

Safe to merge — clean removal of dead code with no remaining references and an intentional version gate to protect the migration.

All Electric references have been scrubbed from the codebase (confirmed by grep), the CI secrets are consistently removed from both preview and production workflows, the lockfile is updated, and the version bump is deliberately designed to force old clients off the now-deleted proxy. No logic bugs or partial removals were found.

apps/api/src/app/api/desktop/version/route.ts — the 0.0.48 → 1.5.0 version bump is a very large jump that will show the update screen to every desktop user below 1.5.0; verify that desktop 1.5.0 is already in production before merging.

Important Files Changed

Filename Overview
.github/workflows/deploy-preview.yml Removes ELECTRIC_URL top-level env var definition and ELECTRIC_URL/ELECTRIC_SECRET from the Vercel API deploy step — clean and consistent with the proxy removal.
.github/workflows/deploy-production.yml Removes ELECTRIC_URL/ELECTRIC_SECRET from the production Vercel API deploy step — mirrors the preview workflow change.
apps/api/package.json Removes @electric-sql/client dependency; no remaining consumers of this package found in the codebase.
apps/api/src/app/api/desktop/version/route.ts Bumps MINIMUM_DESKTOP_VERSION from 0.0.48 → 1.5.0 to force legacy proxy users to update; large jump affects all clients between the two versions.
apps/api/src/app/api/electric/[...path]/route.ts Deleted — the authenticated Electric sync proxy route is fully removed along with its JWT/session auth, org membership check, and column filtering logic.
apps/api/src/app/api/electric/[...path]/utils.ts Deleted — where-clause builder for all Electric-synced tables removed; no remaining references to this utility.
apps/api/src/env.ts Removes ELECTRIC_URL, ELECTRIC_SECRET (required), and ELECTRIC_SOURCE_ID/SECRET (optional) from server env schema; startup will no longer fail if these vars are absent.
apps/api/src/proxy.ts Removes X-Electric-Backend from allowed CORS headers and six electric-* headers from exposed CORS headers; remaining headers are Durable Streams headers only.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    subgraph Before["Before (removed)"]
        DC1["Desktop/Mobile Client\n(< 1.5.0)"] -->|"GET /api/electric/[...path]"| EP["Vercel API\nElectric Proxy\n(auth + org check)"]
        EP -->|"Proxied request\n+ secret"| FLY["Fly.io Electric\nInstance"]
    end

    subgraph After["After (retained)"]
        DC2["Desktop/Mobile Client\n(>= 1.5.0)"] -->|"NEXT_PUBLIC_ELECTRIC_URL"| CF["Cloudflare Worker\napps/electric-proxy"]
        CF --> FLY2["Fly.io Electric\nInstance"]
        DC2 -->|"< 1.5.0 → blocked"| VER["Vercel API\n/api/desktop/version\n(MINIMUM_DESKTOP_VERSION = 1.5.0)"]
    end
Loading

Reviews (1): Last reviewed commit: "chore(api): remove legacy Vercel electri..." | Re-trigger Greptile

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

No issues found across 9 files

The Vercel-hosted `/api/electric/*` route is no longer used by
supported desktop clients. Bumps minimum desktop version to 1.5.0
(the first release after 2026-04-10) so any lingering client on a
pre-1.5.0 build is forced to update before it can heartbeat against
an endpoint that's about to disappear.

Drops the route, its env vars (ELECTRIC_URL/SECRET/SOURCE_*),
`@electric-sql/client` dep, Electric CORS headers, and the matching
env passthroughs in the Vercel deploy workflows. The Cloudflare
worker (apps/electric-proxy) and Fly-hosted Electric instance stay
intact.
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 22, 2026

🧹 Preview Cleanup Complete

The following preview resources have been cleaned up:

  • ✅ Neon database branch

Thank you for your contribution! 🎉

@saddlepaddle saddlepaddle merged commit 5bc8b81 into main Apr 22, 2026
13 checks passed
@Kitenite Kitenite deleted the remove-old-electric branch May 6, 2026 04:52
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