From 3d910929535a99b3f618503d28b51eaa25e6ae07 Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Sun, 12 Oct 2025 00:24:58 +0000 Subject: [PATCH] Fix: Use correct Cloudflare credentials --- supabase/functions/process-oauth-profile/index.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/supabase/functions/process-oauth-profile/index.ts b/supabase/functions/process-oauth-profile/index.ts index c05b5c6b..46c7c265 100644 --- a/supabase/functions/process-oauth-profile/index.ts +++ b/supabase/functions/process-oauth-profile/index.ts @@ -6,16 +6,18 @@ const corsHeaders = { 'Access-Control-Allow-Headers': 'authorization, x-client-info, apikey, content-type', }; +const CLOUDFLARE_ACCOUNT_ID = Deno.env.get('CLOUDFLARE_ACCOUNT_ID'); const CLOUDFLARE_ACCOUNT_HASH = Deno.env.get('CLOUDFLARE_ACCOUNT_HASH'); const CLOUDFLARE_API_TOKEN = Deno.env.get('CLOUDFLARE_IMAGES_API_TOKEN'); // Validate configuration at startup -if (!CLOUDFLARE_ACCOUNT_HASH || !CLOUDFLARE_API_TOKEN) { +if (!CLOUDFLARE_ACCOUNT_ID || !CLOUDFLARE_ACCOUNT_HASH || !CLOUDFLARE_API_TOKEN) { console.error('[OAuth Profile] Missing Cloudflare configuration:', { + hasAccountId: !!CLOUDFLARE_ACCOUNT_ID, hasAccountHash: !!CLOUDFLARE_ACCOUNT_HASH, hasApiToken: !!CLOUDFLARE_API_TOKEN, }); - console.error('[OAuth Profile] Please configure CLOUDFLARE_ACCOUNT_HASH and CLOUDFLARE_IMAGES_API_TOKEN in Supabase Edge Function secrets'); + console.error('[OAuth Profile] Please configure CLOUDFLARE_ACCOUNT_ID, CLOUDFLARE_ACCOUNT_HASH, and CLOUDFLARE_IMAGES_API_TOKEN in Supabase Edge Function secrets'); } interface GoogleUserMetadata { @@ -116,9 +118,10 @@ Deno.serve(async (req) => { // Download and upload avatar to Cloudflare if (avatarUrl) { // Validate secrets before attempting upload - if (!CLOUDFLARE_ACCOUNT_HASH || !CLOUDFLARE_API_TOKEN) { + if (!CLOUDFLARE_ACCOUNT_ID || !CLOUDFLARE_ACCOUNT_HASH || !CLOUDFLARE_API_TOKEN) { console.warn('[OAuth Profile] Cloudflare secrets not configured, skipping avatar upload'); console.warn('[OAuth Profile] Missing:', { + accountId: !CLOUDFLARE_ACCOUNT_ID, accountHash: !CLOUDFLARE_ACCOUNT_HASH, apiToken: !CLOUDFLARE_API_TOKEN, }); @@ -153,7 +156,7 @@ Deno.serve(async (req) => { // Get upload URL from Cloudflare const uploadUrlResponse = await fetch( - `https://api.cloudflare.com/client/v4/accounts/${CLOUDFLARE_ACCOUNT_HASH}/images/v2/direct_upload`, + `https://api.cloudflare.com/client/v4/accounts/${CLOUDFLARE_ACCOUNT_ID}/images/v2/direct_upload`, { method: 'POST', headers: { @@ -196,6 +199,7 @@ Deno.serve(async (req) => { } catch (error) { console.error('[OAuth Profile] Avatar upload failed:', { error: error.message, + accountId: CLOUDFLARE_ACCOUNT_ID, accountHash: CLOUDFLARE_ACCOUNT_HASH, hasToken: !!CLOUDFLARE_API_TOKEN, avatarUrl,