diff --git a/supabase/config.toml b/supabase/config.toml index 43606150..9f79d0ef 100644 --- a/supabase/config.toml +++ b/supabase/config.toml @@ -28,4 +28,7 @@ verify_jwt = true verify_jwt = true [functions.seed-test-data] +verify_jwt = true + +[functions.process-oauth-profile] verify_jwt = true \ No newline at end of file diff --git a/supabase/functions/process-oauth-profile/index.ts b/supabase/functions/process-oauth-profile/index.ts index cd242c87..0933ffef 100644 --- a/supabase/functions/process-oauth-profile/index.ts +++ b/supabase/functions/process-oauth-profile/index.ts @@ -9,6 +9,15 @@ const corsHeaders = { const CLOUDFLARE_ACCOUNT_ID = Deno.env.get('CLOUDFLARE_ACCOUNT_ID'); const CLOUDFLARE_API_TOKEN = Deno.env.get('CLOUDFLARE_IMAGES_API_TOKEN'); +// Validate configuration at startup +if (!CLOUDFLARE_ACCOUNT_ID || !CLOUDFLARE_API_TOKEN) { + console.error('[OAuth Profile] Missing Cloudflare configuration:', { + hasAccountId: !!CLOUDFLARE_ACCOUNT_ID, + hasApiToken: !!CLOUDFLARE_API_TOKEN, + }); + console.error('[OAuth Profile] Please configure CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_IMAGES_API_TOKEN in Supabase Edge Function secrets'); +} + interface GoogleUserMetadata { email?: string; name?: string; @@ -106,8 +115,16 @@ Deno.serve(async (req) => { // Download and upload avatar to Cloudflare if (avatarUrl) { - try { - console.log('[OAuth Profile] Downloading avatar from:', avatarUrl); + // Validate secrets before attempting upload + if (!CLOUDFLARE_ACCOUNT_ID || !CLOUDFLARE_API_TOKEN) { + console.warn('[OAuth Profile] Cloudflare secrets not configured, skipping avatar upload'); + console.warn('[OAuth Profile] Missing:', { + accountId: !CLOUDFLARE_ACCOUNT_ID, + apiToken: !CLOUDFLARE_API_TOKEN, + }); + } else { + try { + console.log('[OAuth Profile] Downloading avatar from:', avatarUrl); // Download image with timeout const controller = new AbortController(); @@ -176,9 +193,15 @@ Deno.serve(async (req) => { } else { throw new Error('Cloudflare upload failed'); } - } catch (error) { - console.error('[OAuth Profile] Avatar upload failed:', error); - // Continue without avatar - don't block profile creation + } catch (error) { + console.error('[OAuth Profile] Avatar upload failed:', { + error: error.message, + accountId: CLOUDFLARE_ACCOUNT_ID, + hasToken: !!CLOUDFLARE_API_TOKEN, + avatarUrl, + }); + // Continue without avatar - don't block profile creation + } } }