ChatSmith_3 / frontend /src /supabaseClient.js
umer6016
Inject Supabase env vars at runtime for Docker deployment
674f2e1
raw
history blame
609 Bytes
import { createClient } from "@supabase/supabase-js";
// Check for runtime config (injected by backend) or build-time config (local dev)
const getEnv = (key) => {
if (typeof window !== "undefined" && window.__ENV__ && window.__ENV__[key]) {
return window.__ENV__[key];
}
return import.meta.env[key];
};
const supabaseUrl = getEnv("VITE_SUPABASE_URL");
const supabaseKey = getEnv("VITE_SUPABASE_ANON_KEY");
if (!supabaseUrl || !supabaseKey) {
console.warn("Supabase credentials missing! App may fail.");
}
export const supabase = createClient(supabaseUrl || "", supabaseKey || "");