mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-23 00:51:12 -05:00
Fix Cloudflare avatar upload
This commit is contained in:
@@ -29,3 +29,6 @@ verify_jwt = true
|
|||||||
|
|
||||||
[functions.seed-test-data]
|
[functions.seed-test-data]
|
||||||
verify_jwt = true
|
verify_jwt = true
|
||||||
|
|
||||||
|
[functions.process-oauth-profile]
|
||||||
|
verify_jwt = true
|
||||||
@@ -9,6 +9,15 @@ const corsHeaders = {
|
|||||||
const CLOUDFLARE_ACCOUNT_ID = Deno.env.get('CLOUDFLARE_ACCOUNT_ID');
|
const CLOUDFLARE_ACCOUNT_ID = Deno.env.get('CLOUDFLARE_ACCOUNT_ID');
|
||||||
const CLOUDFLARE_API_TOKEN = Deno.env.get('CLOUDFLARE_IMAGES_API_TOKEN');
|
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 {
|
interface GoogleUserMetadata {
|
||||||
email?: string;
|
email?: string;
|
||||||
name?: string;
|
name?: string;
|
||||||
@@ -106,6 +115,14 @@ Deno.serve(async (req) => {
|
|||||||
|
|
||||||
// Download and upload avatar to Cloudflare
|
// Download and upload avatar to Cloudflare
|
||||||
if (avatarUrl) {
|
if (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 {
|
try {
|
||||||
console.log('[OAuth Profile] Downloading avatar from:', avatarUrl);
|
console.log('[OAuth Profile] Downloading avatar from:', avatarUrl);
|
||||||
|
|
||||||
@@ -177,10 +194,16 @@ Deno.serve(async (req) => {
|
|||||||
throw new Error('Cloudflare upload failed');
|
throw new Error('Cloudflare upload failed');
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('[OAuth Profile] Avatar upload failed:', 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
|
// Continue without avatar - don't block profile creation
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Update profile with enhanced data
|
// Update profile with enhanced data
|
||||||
const updateData: any = {};
|
const updateData: any = {};
|
||||||
|
|||||||
Reference in New Issue
Block a user