Fix: profil image

This commit is contained in:
Nicolas Cantu 2026-01-05 22:51:30 +01:00
parent e69b0178bc
commit dbe4dba70f
2 changed files with 4 additions and 5 deletions

View File

@ -123,4 +123,3 @@ Pour diagnostiquer le problème avec nostrimg.com :
- Classification des erreurs (404, 403, 500) - Classification des erreurs (404, 403, 500)
- Messages d'erreur plus clairs - Messages d'erreur plus clairs
- Logging amélioré avec aperçu du HTML - Logging amélioré avec aperçu du HTML

View File

@ -261,7 +261,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
const is404 = response.body.includes('404') || response.body.includes('Not Found') || titleMatch?.[1]?.includes('404') const is404 = response.body.includes('404') || response.body.includes('Not Found') || titleMatch?.[1]?.includes('404')
const is403 = response.body.includes('403') || response.body.includes('Forbidden') || titleMatch?.[1]?.includes('403') const is403 = response.body.includes('403') || response.body.includes('Forbidden') || titleMatch?.[1]?.includes('403')
const is500 = response.body.includes('500') || response.body.includes('Internal Server Error') || titleMatch?.[1]?.includes('500') const is500 = response.body.includes('500') || response.body.includes('Internal Server Error') || titleMatch?.[1]?.includes('500')
console.error('NIP-95 proxy HTML response error:', { console.error('NIP-95 proxy HTML response error:', {
targetEndpoint, targetEndpoint,
finalUrl: currentUrl.toString(), finalUrl: currentUrl.toString(),
@ -272,7 +272,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
is500, is500,
bodyPreview: response.body.substring(0, 500), bodyPreview: response.body.substring(0, 500),
contentType: 'HTML (expected JSON)', contentType: 'HTML (expected JSON)',
suggestion: is404 suggestion: is404
? 'The endpoint URL may be incorrect or the endpoint does not exist' ? 'The endpoint URL may be incorrect or the endpoint does not exist'
: is403 : is403
? 'The endpoint may require authentication or have access restrictions' ? 'The endpoint may require authentication or have access restrictions'
@ -280,7 +280,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
? 'The endpoint server encountered an error' ? 'The endpoint server encountered an error'
: 'The endpoint may not be a valid NIP-95 upload endpoint or may require specific headers', : 'The endpoint may not be a valid NIP-95 upload endpoint or may require specific headers',
}) })
let userMessage = `Endpoint returned an HTML error page instead of JSON` let userMessage = `Endpoint returned an HTML error page instead of JSON`
if (is404) { if (is404) {
userMessage = `Endpoint not found (404). The URL may be incorrect: ${currentUrl.toString()}` userMessage = `Endpoint not found (404). The URL may be incorrect: ${currentUrl.toString()}`
@ -291,7 +291,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
} else { } else {
userMessage = `Endpoint returned an HTML error page instead of JSON. The endpoint may be unavailable, the URL may be incorrect, or specific headers may be required. Error: ${errorText}` userMessage = `Endpoint returned an HTML error page instead of JSON. The endpoint may be unavailable, the URL may be incorrect, or specific headers may be required. Error: ${errorText}`
} }
return res.status(500).json({ return res.status(500).json({
error: userMessage, error: userMessage,
}) })