fix(auth): expose supabase publishable key to client-side
This commit is contained in:
parent
684c84a7ed
commit
984b8b00fd
1 changed files with 3 additions and 3 deletions
|
|
@ -1,14 +1,14 @@
|
|||
import { createClient } from "@supabase/supabase-js";
|
||||
|
||||
const supabaseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL;
|
||||
const supabasePublishableKey = process.env.SUPABASE_PUBLISHABLE_KEY;
|
||||
const supabasePublishableKey = process.env.NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY || process.env.SUPABASE_PUBLISHABLE_KEY;
|
||||
|
||||
if (!supabaseUrl) {
|
||||
throw new Error("Missing env.NEXT_PUBLIC_SUPABASE_URL");
|
||||
}
|
||||
|
||||
if (!supabasePublishableKey) {
|
||||
throw new Error("Missing env.SUPABASE_PUBLISHABLE_KEY");
|
||||
throw new Error("Missing env.NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY or env.SUPABASE_PUBLISHABLE_KEY");
|
||||
}
|
||||
|
||||
// Client-side/public Supabase client
|
||||
|
|
@ -17,7 +17,7 @@ export const supabase = createClient(supabaseUrl, supabasePublishableKey);
|
|||
// Server-side admin/secret Supabase client
|
||||
export const createServerSupabaseClient = () => {
|
||||
const secretKey = process.env.SUPABASE_SECRET_KEY;
|
||||
const publishableKey = process.env.SUPABASE_PUBLISHABLE_KEY;
|
||||
const publishableKey = process.env.NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY || process.env.SUPABASE_PUBLISHABLE_KEY;
|
||||
|
||||
// Use secret key if available and not a placeholder; otherwise fall back to publishable key
|
||||
const activeKey = (secretKey && secretKey !== "sb_secret_your_secret_key")
|
||||
|
|
|
|||
Loading…
Reference in a new issue