File tree Expand file tree Collapse file tree 3 files changed +20
-6
lines changed Expand file tree Collapse file tree 3 files changed +20
-6
lines changed Original file line number Diff line number Diff line change 1414.env.development.local
1515.env.test.local
1616.env.production.local
17+ .env
1718
1819npm-debug.log *
1920yarn-debug.log *
Original file line number Diff line number Diff line change @@ -90,4 +90,8 @@ module.exports = {
9090 } ) ,
9191 ] ,
9292 ] ,
93+ customFields : {
94+ supabaseUrl : process . env . NEXT_PUBLIC_SUPABASE_URL ,
95+ supabaseAnonKey : process . env . NEXT_PUBLIC_SUPABASE_ANON_KEY ,
96+ } ,
9397}
Original file line number Diff line number Diff line change @@ -44,11 +44,15 @@ const TechBackground = () => (
4444 </ div >
4545) ;
4646
47- // Initialize Supabase client (add these environment variables to your .env)
48- const supabase = createClient (
49- process . env . NEXT_PUBLIC_SUPABASE_URL ,
50- process . env . NEXT_PUBLIC_SUPABASE_ANON_KEY
51- )
47+ // Move the client initialization inside a function
48+ const getSupabaseClient = ( ) => {
49+ if ( typeof window === 'undefined' ) return null ; // Return null during SSR/build
50+
51+ return createClient (
52+ process . env . NEXT_PUBLIC_SUPABASE_URL ,
53+ process . env . NEXT_PUBLIC_SUPABASE_ANON_KEY
54+ ) ;
55+ } ;
5256
5357export default function Home ( ) {
5458 const { siteConfig } = useDocusaurusContext ( ) ;
@@ -60,9 +64,14 @@ export default function Home() {
6064 setStatus ( 'sending' ) ;
6165
6266 try {
67+ const supabase = getSupabaseClient ( ) ;
68+ if ( ! supabase ) {
69+ throw new Error ( 'Supabase client not initialized' ) ;
70+ }
71+
6372 const { error } = await supabase
6473 . from ( 'subscribers' )
65- . insert ( [ { email : email } ] )
74+ . insert ( [ { email : email } ] ) ;
6675
6776 if ( error ) throw error ;
6877
You can’t perform that action at this time.
0 commit comments