@@ -4,12 +4,15 @@ import { createClient } from '@supabase/supabase-js';
44const supabaseUrl = process . env . NEXT_PUBLIC_SUPABASE_URL || 'https://mbhrkgzrswaysrmpdehz.supabase.co' ;
55const supabaseAnonKey = process . env . NEXT_PUBLIC_SUPABASE_ANON_KEY || 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Im1iaHJrZ3pyc3dheXNybXBkZWh6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NTQ1MTU2NjAsImV4cCI6MjA3MDA5MTY2MH0._JP4S6jVxYt0w7mSL2Rci59pSii0kDK1g9qfgFFtXKI' ;
66
7- console . log ( 'Supabase initialization:' , {
8- url : supabaseUrl ,
9- keyLength : supabaseAnonKey ?. length ,
10- keyPrefix : supabaseAnonKey ?. substring ( 0 , 20 ) + '...' ,
11- env : typeof window !== 'undefined' ? 'browser' : 'server'
12- } ) ;
7+ // Only log in browser environment
8+ if ( typeof window !== 'undefined' ) {
9+ console . log ( 'Supabase initialization:' , {
10+ url : supabaseUrl ,
11+ keyLength : supabaseAnonKey ?. length ,
12+ keyPrefix : supabaseAnonKey ?. substring ( 0 , 20 ) + '...' ,
13+ env : 'browser'
14+ } ) ;
15+ }
1316
1417export const supabase = createClient ( supabaseUrl , supabaseAnonKey , {
1518 auth : {
@@ -23,62 +26,64 @@ export const supabase = createClient(supabaseUrl, supabaseAnonKey, {
2326 }
2427} ) ;
2528
26- // Add request interceptor for debugging
27- const originalFrom = supabase . from . bind ( supabase ) ;
28- ( supabase as any ) . from = ( table : string ) => {
29- console . log ( `[Supabase] Accessing table: ${ table } ` ) ;
30- const tableRef = originalFrom ( table ) ;
31-
32- // Intercept select
33- const originalSelect = tableRef . select . bind ( tableRef ) ;
34- tableRef . select = ( ...args : any [ ] ) => {
35- console . log ( `[Supabase] SELECT from ${ table } ` , args ) ;
36- const query = originalSelect ( ...args ) ;
29+ // Add request interceptor for debugging only in browser
30+ if ( typeof window !== 'undefined' ) {
31+ const originalFrom = supabase . from . bind ( supabase ) ;
32+ ( supabase as any ) . from = ( table : string ) => {
33+ console . log ( `[Supabase] Accessing table: ${ table } ` ) ;
34+ const tableRef = originalFrom ( table ) ;
3735
38- // Intercept the promise
39- const originalThen = query . then . bind ( query ) ;
40- query . then = ( onFulfilled : any , onRejected : any ) => {
41- return originalThen (
42- ( result : any ) => {
43- console . log ( `[Supabase] SELECT ${ table } result:` , result ) ;
44- return onFulfilled ?.( result ) ;
45- } ,
46- ( error : any ) => {
47- console . error ( `[Supabase] SELECT ${ table } error:` , error ) ;
48- return onRejected ?.( error ) ;
49- }
50- ) ;
36+ // Intercept select
37+ const originalSelect = tableRef . select . bind ( tableRef ) ;
38+ tableRef . select = ( ...args : any [ ] ) => {
39+ console . log ( `[Supabase] SELECT from ${ table } ` , args ) ;
40+ const query = originalSelect ( ...args ) ;
41+
42+ // Intercept the promise
43+ const originalThen = query . then . bind ( query ) ;
44+ query . then = ( onFulfilled : any , onRejected : any ) => {
45+ return originalThen (
46+ ( result : any ) => {
47+ console . log ( `[Supabase] SELECT ${ table } result:` , result ) ;
48+ return onFulfilled ?.( result ) ;
49+ } ,
50+ ( error : any ) => {
51+ console . error ( `[Supabase] SELECT ${ table } error:` , error ) ;
52+ return onRejected ?.( error ) ;
53+ }
54+ ) ;
55+ } ;
56+
57+ return query ;
5158 } ;
5259
53- return query ;
54- } ;
55-
56- // Intercept insert
57- const originalInsert = tableRef . insert . bind ( tableRef ) ;
58- tableRef . insert = ( ... args : any [ ] ) => {
59- console . log ( `[Supabase] INSERT into ${ table } ` , args ) ;
60- const query = originalInsert ( ... args ) ;
61-
62- // Intercept the promise
63- const originalThen = query . then . bind ( query ) ;
64- query . then = ( onFulfilled : any , onRejected : any ) => {
65- return originalThen (
66- ( result : any ) => {
67- console . log ( `[Supabase] INSERT ${ table } result:` , result ) ;
68- return onFulfilled ?. ( result ) ;
69- } ,
70- ( error : any ) => {
71- console . error ( `[Supabase] INSERT ${ table } error:` , error ) ;
72- return onRejected ?. ( error ) ;
73- }
74- ) ;
60+ // Intercept insert
61+ const originalInsert = tableRef . insert . bind ( tableRef ) ;
62+ tableRef . insert = ( ... args : any [ ] ) => {
63+ console . log ( `[Supabase] INSERT into ${ table } ` , args ) ;
64+ const query = originalInsert ( ... args ) ;
65+
66+ // Intercept the promise
67+ const originalThen = query . then . bind ( query ) ;
68+ query . then = ( onFulfilled : any , onRejected : any ) => {
69+ return originalThen (
70+ ( result : any ) => {
71+ console . log ( `[Supabase] INSERT ${ table } result:` , result ) ;
72+ return onFulfilled ?. ( result ) ;
73+ } ,
74+ ( error : any ) => {
75+ console . error ( `[Supabase] INSERT ${ table } error:` , error ) ;
76+ return onRejected ?. ( error ) ;
77+ }
78+ ) ;
79+ } ;
80+
81+ return query ;
7582 } ;
7683
77- return query ;
84+ return tableRef ;
7885 } ;
79-
80- return tableRef ;
81- } ;
86+ }
8287
8388// Database schema types
8489export interface TeamMember {
0 commit comments