Skip to content

Commit d2c694a

Browse files
committed
Require auth for AI features - add session check before calling Edge Function
1 parent 8caafbd commit d2c694a

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

‎src/lib/ai/client.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,14 @@ async function callSupabaseAI(
6565
const { data: sessionData } = await supabase.auth.getSession();
6666
const accessToken = sessionData.session?.access_token;
6767

68+
// Require authentication for AI features
69+
if (!accessToken) {
70+
throw new Error('Please sign in to use AI features');
71+
}
72+
6873
// Wrap the API call with timeout
6974
const invokePromise = supabase.functions.invoke('ai', {
70-
headers: accessToken ? { Authorization: `Bearer ${accessToken}` } : undefined,
75+
headers: { Authorization: `Bearer ${accessToken}` },
7176
body: {
7277
feature,
7378
input,

0 commit comments

Comments
 (0)