mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-23 03:31:13 -05:00
Fix Cloudflare avatar upload
This commit is contained in:
@@ -28,4 +28,7 @@ verify_jwt = true
|
|||||||
verify_jwt = true
|
verify_jwt = true
|
||||||
|
|
||||||
[functions.seed-test-data]
|
[functions.seed-test-data]
|
||||||
|
verify_jwt = true
|
||||||
|
|
||||||
|
[functions.process-oauth-profile]
|
||||||
verify_jwt = true
|
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,8 +115,16 @@ Deno.serve(async (req) => {
|
|||||||
|
|
||||||
// Download and upload avatar to Cloudflare
|
// Download and upload avatar to Cloudflare
|
||||||
if (avatarUrl) {
|
if (avatarUrl) {
|
||||||
try {
|
// Validate secrets before attempting upload
|
||||||
console.log('[OAuth Profile] Downloading avatar from:', avatarUrl);
|
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
|
// Download image with timeout
|
||||||
const controller = new AbortController();
|
const controller = new AbortController();
|
||||||
@@ -176,9 +193,15 @@ Deno.serve(async (req) => {
|
|||||||
} else {
|
} else {
|
||||||
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:', {
|
||||||
// Continue without avatar - don't block profile creation
|
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