Set up Supabase client configuration for self-hosted instance

This commit is contained in:
boilerrat 2025-03-04 22:46:15 -05:00
parent 1b73482ce8
commit d485fc1694
2 changed files with 16 additions and 2 deletions

1
.gitignore vendored
View File

@ -32,6 +32,7 @@ yarn-error.log*
# env files (can opt-in for committing if needed)
.env*
.env.local
# vercel
.vercel

View File

@ -1,10 +1,23 @@
import { createClient } from '@supabase/supabase-js';
const supabaseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL || '';
const supabaseAnonKey = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY || '';
const supabaseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL as string;
const supabaseAnonKey = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY as string;
if (!supabaseUrl || !supabaseAnonKey) {
throw new Error('Missing Supabase environment variables');
}
export const supabase = createClient(supabaseUrl, supabaseAnonKey);
// For server-side functions that need admin privileges
export const getServiceSupabase = () => {
const serviceRoleKey = process.env.SUPABASE_SERVICE_ROLE_KEY;
if (!serviceRoleKey) {
throw new Error('Missing service role key');
}
return createClient(supabaseUrl, serviceRoleKey);
};
export type Tables = {
products: {
id: string;