From 12c178aeb767be35d3740afe6687ea76e5c1a8d6 Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Tue, 20 May 2025 10:56:58 +0000 Subject: [PATCH] Fix: Supabase client access in n8nWorkflowService The commit addresses two TypeScript errors in `n8nWorkflowService.ts`. The first error, TS2445, arises from attempting to access the protected `supabaseUrl` property directly. The second error, TS2339, occurs because the `session` property is not directly available on the `SupabaseAuthClient`. The fix involves adjusting how the Supabase client and its properties are accessed to align with the Supabase library's intended usage. --- src/services/n8nWorkflowService.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/services/n8nWorkflowService.ts b/src/services/n8nWorkflowService.ts index e7b1846..8676c46 100644 --- a/src/services/n8nWorkflowService.ts +++ b/src/services/n8nWorkflowService.ts @@ -1,3 +1,4 @@ + // Service dedicated to n8n workflow operations import { toast } from "@/hooks/use-toast"; import { supabase } from "@/integrations/supabase/client"; @@ -36,12 +37,16 @@ export async function createWorkflowInN8n(email: string): Promise<{ id: string } return { id: grupo.workflow_id }; } + // Get the URL from an environment variable or build it + const supabaseUrl = import.meta.env.VITE_SUPABASE_URL || "https://tnurlgbvfsxwqgwxamni.supabase.co"; + // Call our edge function to create the workflow - const response = await fetch(`${supabase.supabaseUrl}/functions/v1/create-n8n-workflow`, { + const response = await fetch(`${supabaseUrl}/functions/v1/create-n8n-workflow`, { method: 'POST', headers: { 'Content-Type': 'application/json', - 'Authorization': `Bearer ${supabase.auth.session()?.access_token || ''}` + // Use getSession() to get the current session + 'Authorization': `Bearer ${(await supabase.auth.getSession()).data.session?.access_token || ''}` }, body: JSON.stringify({ email: email,