vxkyyy commited on
Commit
b181ac8
·
1 Parent(s): e1af51b

fix: explicit TS types for Supabase session to fix Vercel build

Browse files
web/src/App.tsx CHANGED
@@ -1,5 +1,5 @@
1
  import { useEffect, useMemo, useState } from 'react';
2
- import type { Session } from '@supabase/supabase-js';
3
  import { supabase } from './supabaseClient';
4
  import { AuthPage } from './components/AuthPage';
5
  import { Dashboard } from './pages/Dashboard';
@@ -30,11 +30,11 @@ const App = () => {
30
  setAuthLoading(false);
31
  return;
32
  }
33
- supabase.auth.getSession().then(({ data: { session: s } }) => {
34
  setSession(s);
35
  setAuthLoading(false);
36
  }).catch(() => setAuthLoading(false));
37
- const { data: { subscription } } = supabase.auth.onAuthStateChange((_event, s) => {
38
  setSession(s);
39
  });
40
  return () => subscription.unsubscribe();
@@ -89,9 +89,8 @@ const App = () => {
89
  );
90
  }
91
 
92
- // ── Auth gate (skip in local dev when Supabase not configured) ──
93
  if (AUTH_ENABLED && !session) {
94
- return <AuthPage onAuth={() => supabase.auth.getSession().then(({ data: { session: s } }) => setSession(s))} />;
95
  }
96
 
97
  return (
 
1
  import { useEffect, useMemo, useState } from 'react';
2
+ import type { Session, AuthChangeEvent } from '@supabase/supabase-js';
3
  import { supabase } from './supabaseClient';
4
  import { AuthPage } from './components/AuthPage';
5
  import { Dashboard } from './pages/Dashboard';
 
30
  setAuthLoading(false);
31
  return;
32
  }
33
+ supabase.auth.getSession().then(({ data: { session: s } }: { data: { session: Session | null } }) => {
34
  setSession(s);
35
  setAuthLoading(false);
36
  }).catch(() => setAuthLoading(false));
37
+ const { data: { subscription } } = supabase.auth.onAuthStateChange((_event: AuthChangeEvent, s: Session | null) => {
38
  setSession(s);
39
  });
40
  return () => subscription.unsubscribe();
 
89
  );
90
  }
91
 
 
92
  if (AUTH_ENABLED && !session) {
93
+ return <AuthPage onAuth={() => supabase.auth.getSession().then(({ data: { session: s } }: { data: { session: Session | null } }) => setSession(s))} />;
94
  }
95
 
96
  return (
web/src/components/AuthPage.tsx CHANGED
@@ -23,7 +23,13 @@ export const AuthPage = ({ onAuth }: { onAuth: () => void }) => {
23
  if (err) throw err;
24
  onAuth();
25
  } else {
26
- const { error: err } = await supabase.auth.signUp({ email, password });
 
 
 
 
 
 
27
  if (err) throw err;
28
  setSuccessMsg('We sent you a confirmation link. Check your email to continue.');
29
  }
 
23
  if (err) throw err;
24
  onAuth();
25
  } else {
26
+ const { error: err } = await supabase.auth.signUp({
27
+ email,
28
+ password,
29
+ options: {
30
+ emailRedirectTo: window.location.origin
31
+ }
32
+ });
33
  if (err) throw err;
34
  setSuccessMsg('We sent you a confirmation link. Check your email to continue.');
35
  }