mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-22 01:11:13 -05:00
Fix Cloudflare avatar upload
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user