feat: LOCAL_ONLY mode for local development without Firebase/GCP#3696
Open
evand wants to merge 16 commits intomanifoldmarkets:mainfrom
Open
feat: LOCAL_ONLY mode for local development without Firebase/GCP#3696evand wants to merge 16 commits intomanifoldmarkets:mainfrom
evand wants to merge 16 commits intomanifoldmarkets:mainfrom
Conversation
Loads all schema SQL files into a local Supabase instance in the correct dependency order (seed → functions → core tables → rest → views). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When LOCAL_ONLY=true is set in the environment: - API server skips Firebase init, Secret Manager, and GCP metrics - Scheduler skips Firebase init, Secret Manager, and GCP metrics - Supabase direct client connects via SUPABASE_HOST/SUPABASE_PORT env vars instead of cloud instance IDs - createClient() accepts full URLs (not just instance IDs) for local Supabase connections - .env.local files are now gitignored Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Backend: - endpoint.ts accepts X-Local-User header in LOCAL_ONLY mode, bypassing Firebase JWT validation Frontend (common/util/api.ts): - setLocalOnlyUserId() sets a user ID sent as X-Local-User header on all API calls Frontend (auth-context.tsx): - LOCAL_ONLY mode auto-logins as NEXT_PUBLIC_LOCAL_TEST_USER - Fetches user from local API instead of Firebase auth - Sets local user ID synchronously before async fetch Frontend (supabase/db.ts, admin-db.ts): - Support NEXT_PUBLIC_SUPABASE_URL/KEY for local Supabase connection Incorporates fixes from GabrielleVivissi: Supabase client URL support, immediate user ID set in auth-context. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- docs/local-development.md: comprehensive setup guide - .env.local.template files for API, scheduler, and web frontend with default Supabase keys from `npx supabase start` Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Wrap migration SQL in DO blocks with exception handlers so they skip gracefully when tables don't exist yet (during local dev where schema is loaded after supabase start). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The spaced-out comment delimiters `/ * ... * /` are not valid SQL. Replace with standard `/* ... */` block comments. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- isProd() returns false early in LOCAL_ONLY mode (avoids admin.app()) - stripe-endpoints.ts: lazy-init Firestore (was module-level admin.firestore()) - endpoint.ts: fix TypeScript cast for local user credentials - Fix 20 SQL files with invalid `constraint primary key` syntax (should be just `primary key`) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When LOCAL_ONLY=true and no X-Local-User header is present, throw a clean 401 instead of calling admin.auth() which crashes since Firebase isn't initialized. This lets MaybeAuthedEndpoint and optional-auth typedEndpoint paths handle unauthenticated requests gracefully. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Three-pass function loading to handle: 1. functions.sql internal dependency (add_creator_name_to_description depends on extract_text_from_rich_text_json defined later in file) 2. Circular dependency between functions.sql and table SQL files Also fixes: - Trailing comma in answers.sql CREATE TABLE statement - Missing status_type enum for mod_reports.sql - Strips `leakproof` keyword (local postgres user isn't superuser) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Someone is attempting to deploy a commit to the Manifold Markets Team on Vercel. A member of the Team first needs to authorize it. |
5 tasks
Private user data may not include blockedUserIds/blockedByUserIds arrays (e.g. in local dev with minimal test data). Use optional chaining to prevent TypeError. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
API calls from hooks fire before the async useEffect in auth-context sets the local user ID, causing 401 "Missing X-Local-User header" errors. Fix by initializing localOnlyUserId from NEXT_PUBLIC_LOCAL_TEST_USER_ID at module load time. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- seed-local-data.sql: Complete test data with all JSONB fields the frontend expects (probChanges, description, createdTime, closeTime, blockedUserIds, etc.) - Updated docs/local-development.md with correct SQL, proper ordering, NEXT_PUBLIC_LOCAL_TEST_USER_ID documentation, reset/troubleshooting - Exclude seed-local-data.sql from load-local-schema.sh table loop Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The autogenerated table .sql files define CREATE TRIGGER before CREATE FUNCTION, so triggers silently fail on first load. Add Phase 5b to re-run table files containing triggers after all functions exist. Also fix seed-local-data.sql: - Add collectedFees to contract JSONB (bet panel crashes without it) - Enable CASH token in system_trading_status - Set isAdvancedTrader on test user (exposes limit order UI)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a
LOCAL_ONLY=truemode that enables fully local Manifold development using only Supabase (Docker), without Firebase credentials or GCP access. This makes it much easier for new contributors to get started.Changes
Backend API (
backend/api/src/serve.ts)LOCAL_ONLY=trueAuth bypass (
backend/api/src/helpers/endpoint.ts)X-Local-Userheader as trusted auth in LOCAL_ONLY modeSupabase connection (
backend/shared/src/supabase/init.ts)SUPABASE_HOST/SUPABASE_PORTenv vars for local postgresFrontend (
web/components/auth-context.tsx,web/lib/supabase/db.ts)NEXT_PUBLIC_SUPABASE_URL/KEYenv vars for local SupabaseSchema loading (
backend/supabase/load-local-schema.sh)leakproofkeyword (local postgres user isn't superuser)SQL fixes for local dev
constraint primary keysyntax in 20 auto-generated schema filesanswers.sqlseed.sqlstatus_typeenum formod_reports.sqlScheduler (
backend/scheduler/src/index.ts)Documentation
docs/local-development.md— comprehensive setup guide.env.local.templatefiles for api, scheduler, and webCredits
Incorporates fixes from @GabrielleVivissi's contributions to #3644:
NEXT_PUBLIC_SUPABASE_URL/KEYenv var supportSupersedes #3644 (rebased on current main).
Test plan
npx supabase start+./load-local-schema.shcreates all 111+ tablesGET /v0/user/testuserreturns userGET /v0/slug/will-this-test-passreturns market with pool/probabilityGET /v0/mewithX-Local-Userheader returns authenticated userGET /v0/search-marketsreturns results🤖 Generated with Claude Code