@@ -282,6 +282,17 @@ export default function ProfileForm({ params }: PageProps) {
282282 e . preventDefault ( )
283283 setSaving ( true )
284284
285+ // DEBUG: Log información crítica
286+ console . log ( '=== PROFILE SAVE DEBUG ===' )
287+ console . log ( '1. Session address:' , session ?. address )
288+ console . log ( '2. Wallet address:' , address )
289+ console . log ( '3. Are they equal?' , session ?. address === address )
290+ console . log ( '4. User Agent:' , navigator . userAgent )
291+ console . log ( '5. Is OKX Browser?' , navigator . userAgent . includes ( 'OKX' ) )
292+
293+ const csrfToken = await getCsrfToken ( )
294+ console . log ( '6. CSRF Token length:' , csrfToken ?. length )
295+
285296 try {
286297 if ( ! process . env . NEXT_PUBLIC_API_UPDATE_USER ) {
287298 alert ( 'Undefined NEXT_PUBLIC_API_UPDATE_USER' )
@@ -294,8 +305,6 @@ export default function ProfileForm({ params }: PageProps) {
294305 religion_id : profile . religion ,
295306 pais_id : profile . country ,
296307 }
297-
298- const csrfToken = await getCsrfToken ( )
299308 let url = process . env . NEXT_PUBLIC_API_UPDATE_USER . replace (
300309 'usuario_id' ,
301310 profile . userId ,
@@ -312,9 +321,31 @@ export default function ProfileForm({ params }: PageProps) {
312321 } )
313322
314323 if ( ! response . ok ) {
315- throw new Error ( 'Failed to save profile' )
324+ const errorText = await response . text ( )
325+ console . log ( '❌ Profile save failed:' , {
326+ status : response . status ,
327+ statusText : response . statusText ,
328+ error : errorText . substring ( 0 , 500 ) , // Primeros 500 caracteres
329+ url : url ,
330+ is_okx : navigator . userAgent . includes ( 'OKX' )
331+ } )
332+ throw new Error ( `Failed to save profile: ${ response . status } ${ response . statusText } ` )
316333 }
317334
335+ // Intentar parsear respuesta JSON para logging
336+ let responseData = null
337+ try {
338+ responseData = await response . json ( )
339+ } catch ( e ) {
340+ // No es JSON, usar texto plano
341+ responseData = await response . text ( )
342+ }
343+ console . log ( '✅ Profile save successful:' , {
344+ status : response . status ,
345+ url : url ,
346+ is_okx : navigator . userAgent . includes ( 'OKX' ) ,
347+ response : typeof responseData === 'string' ? responseData . substring ( 0 , 200 ) : responseData
348+ } )
318349 alert ( 'Profile updated successfully' )
319350 } catch ( error ) {
320351 alert ( 'Failed to save profile' )
0 commit comments