fix(api): prevent Vercel CDN from caching Electric responses#1864
Conversation
Vercel's edge cache can serve stale shape data for Electric requests because it doesn't properly handle offset-based cache keying. Disable Vercel CDN caching on the Electric proxy route per Electric's docs.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review infoConfiguration used: defaults Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughA new Vercel configuration file is added to the API directory that establishes CDN cache control headers. The configuration targets Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 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 |
🧹 Preview Cleanup CompleteThe following preview resources have been cleaned up:
Thank you for your contribution! 🎉 |
* Revert "fix(api): prevent Vercel CDN from caching Electric responses (#1864)" This reverts commit ae64aa4. * feat(electric-proxy): add Cloudflare Worker proxy for Electric with JWT auth Replace the API server's Electric proxy with a standalone Cloudflare Worker that authenticates via JWT instead of session tokens. This decouples Electric from the API server and enables edge caching via Cloudflare's Cache API. The worker supports both local Docker Electric (ELECTRIC_URL + ELECTRIC_SECRET) and Electric Cloud (ELECTRIC_SOURCE_ID + ELECTRIC_SOURCE_SECRET), matching the dual-mode pattern from the old API proxy. Desktop changes: - Rename electricJwt → jwt, add jwtClient() plugin to auth client - Fetch JWT from authClient.token() response body during hydration - Periodic JWT refresh every 50 minutes - Collections use JWT-only auth headers for the worker * refactor(electric-proxy): move AuthContext/WhereClause to auth.ts, simplify types.ts to Env only * feat: point desktop Electric URL to Cloudflare Worker and add CI deploy job * fix: add local Electric vars to .dev.vars, guard JWT hydration, accept JWTs in old proxy * feat: add electric-cloud feature flag, simplify proxy routing - Old Vercel proxy always routes to Fly.io (removed cloud/email check) - Cloudflare Worker always routes to Electric Cloud (removed dual-mode) - Desktop uses PostHog `electric-cloud` flag to pick proxy - Default: old proxy (Fly.io), flag on: Cloudflare Worker (Electric Cloud) * fix: mock posthog-js/react in CollectionsProvider test
Summary
vercel.jsontoapps/apithat setsCDN-Cache-Control: no-storeandVercel-CDN-Cache-Control: no-storeon/api/electric/*routesTest plan
bun run typecheck --filter=@superset/apipassesSummary by CodeRabbit