Zelyanoth commited on
Commit
4f72af8
·
1 Parent(s): 9bb4b11
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
- const supabaseUrl = import.meta.env.VITE_SUPABASE_URL;
5
- const supabaseAnonKey = import.meta.env.VITE_SUPABASE_ANON_KEY;
 
 
6
 
7
  // Validate configuration
8
  if (!supabaseUrl) {
9
- console.error('Missing VITE_SUPABASE_URL environment variable');
10
  }
11
 
12
  if (!supabaseAnonKey) {
13
- console.error('Missing VITE_SUPABASE_ANON_KEY environment variable');
14
  }
15
 
16
  // Create Supabase client instance
17
- export const supabase = createClient(supabaseUrl, supabaseAnonKey, {
18
- // Optional: Add any additional configuration options here
19
- auth: {
20
- // Automatically refresh the session if it's close to expiring
21
- autoRefreshToken: true,
22
- // Persist the session in local storage
23
- persistSession: true,
24
- // Detect changes to the session (e.g., token refresh)
25
- detectSessionInUrl: true
26
- },
27
- // Global fetch options
28
- global: {
29
- // Set a default timeout for requests (in milliseconds)
30
- headers: {
31
- 'X-Client-Info': 'lin-app/1.0'
 
 
 
 
 
 
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;