jj
Browse files
frontend/src/services/supabaseClient.js
CHANGED
|
@@ -1,36 +1,44 @@
|
|
| 1 |
import { createClient } from '@supabase/supabase-js';
|
| 2 |
|
| 3 |
// Supabase configuration from environment variables
|
| 4 |
-
|
| 5 |
-
|
|
|
|
|
|
|
| 6 |
|
| 7 |
// Validate configuration
|
| 8 |
if (!supabaseUrl) {
|
| 9 |
-
console.error('Missing
|
| 10 |
}
|
| 11 |
|
| 12 |
if (!supabaseAnonKey) {
|
| 13 |
-
console.error('Missing
|
| 14 |
}
|
| 15 |
|
| 16 |
// Create Supabase client instance
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
}
|
| 33 |
}
|
| 34 |
-
|
| 35 |
|
| 36 |
export default supabase;
|
|
|
|
| 1 |
import { createClient } from '@supabase/supabase-js';
|
| 2 |
|
| 3 |
// Supabase configuration from environment variables
|
| 4 |
+
// Try VITE_ prefixed variables first (for local development)
|
| 5 |
+
// Fall back to non-prefixed variables (for Hugging Face deployment)
|
| 6 |
+
const supabaseUrl = import.meta.env.VITE_SUPABASE_URL || import.meta.env.SUPABASE_URL;
|
| 7 |
+
const supabaseAnonKey = import.meta.env.VITE_SUPABASE_ANON_KEY || import.meta.env.SUPABASE_KEY;
|
| 8 |
|
| 9 |
// Validate configuration
|
| 10 |
if (!supabaseUrl) {
|
| 11 |
+
console.error('Missing SUPABASE_URL environment variable. Please check your environment variables or .env file.');
|
| 12 |
}
|
| 13 |
|
| 14 |
if (!supabaseAnonKey) {
|
| 15 |
+
console.error('Missing SUPABASE_KEY environment variable. Please check your environment variables or .env file.');
|
| 16 |
}
|
| 17 |
|
| 18 |
// Create Supabase client instance
|
| 19 |
+
// If environment variables are not set, we'll still create the client but it won't work
|
| 20 |
+
// This allows the app to load but will show errors when trying to use Supabase
|
| 21 |
+
export const supabase = createClient(
|
| 22 |
+
supabaseUrl || 'https://your-project.supabase.co',
|
| 23 |
+
supabaseAnonKey || 'your-anon-key',
|
| 24 |
+
{
|
| 25 |
+
// Optional: Add any additional configuration options here
|
| 26 |
+
auth: {
|
| 27 |
+
// Automatically refresh the session if it's close to expiring
|
| 28 |
+
autoRefreshToken: true,
|
| 29 |
+
// Persist the session in local storage
|
| 30 |
+
persistSession: true,
|
| 31 |
+
// Detect changes to the session (e.g., token refresh)
|
| 32 |
+
detectSessionInUrl: true
|
| 33 |
+
},
|
| 34 |
+
// Global fetch options
|
| 35 |
+
global: {
|
| 36 |
+
// Set a default timeout for requests (in milliseconds)
|
| 37 |
+
headers: {
|
| 38 |
+
'X-Client-Info': 'lin-app/1.0'
|
| 39 |
+
}
|
| 40 |
}
|
| 41 |
}
|
| 42 |
+
);
|
| 43 |
|
| 44 |
export default supabase;
|