fix(dev): route Supabase same-origin via /__supabase proxy
app-ci-deploy / test-build-deploy (push) Has been cancelled
app-ci-deploy / test-build-deploy (push) Has been cancelled
app-dev built with --mode production was baking the PROD Supabase URL (.env) into the bundle, so browser auth went cross-origin to supa.classroomcopilot.ai and was CORS-blocked (and hit the wrong user store). Mirror the /__ccapi fix: - Dockerfile: nginx /__supabase/ -> dev Supabase .94:8000 (+WS upgrade for realtime) - supabaseClient.ts: resolve a leading-slash VITE_SUPABASE_URL against window.location.origin so supabase-js gets an absolute same-origin URL - docker-compose.dev.yml: bake VITE_SUPABASE_URL=/__supabase (like VITE_API_BASE) Browser now talks only to the app host (Tailscale or LAN), no CORS, dev .94 store. Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
ef13a124dd
commit
2ccfb9ccd6
@@ -1,9 +1,17 @@
|
||||
import { createClient, SupabaseClient } from '@supabase/supabase-js';
|
||||
import { logger } from './debugConfig';
|
||||
|
||||
const supabaseUrl = import.meta.env.VITE_SUPABASE_URL;
|
||||
const rawSupabaseUrl = import.meta.env.VITE_SUPABASE_URL;
|
||||
const supabaseAnonKey = import.meta.env.VITE_SUPABASE_ANON_KEY;
|
||||
|
||||
// Same-origin proxy support: a leading-slash value (e.g. "/__supabase") is
|
||||
// resolved against the current browser origin so supabase-js receives an
|
||||
// absolute URL while every request stays same-origin (no CORS) and routes
|
||||
// through the app host's /__supabase nginx proxy to the backend Supabase.
|
||||
const supabaseUrl = rawSupabaseUrl?.startsWith('/')
|
||||
? `${window.location.origin}${rawSupabaseUrl}`
|
||||
: rawSupabaseUrl;
|
||||
|
||||
if (!supabaseUrl || !supabaseAnonKey) {
|
||||
throw new Error('Missing Supabase configuration');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user