fix: propagate Shopify 404 through upload route so client retry triggers correctly

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-24 20:40:50 +02:00
parent 5e1b864ce7
commit 03770d1a76
2 changed files with 8 additions and 1 deletions
+2 -1
View File
@@ -26,6 +26,7 @@ export async function POST(req: NextRequest) {
return NextResponse.json(result)
} catch (err) {
const message = err instanceof Error ? err.message : 'Erreur inconnue'
return NextResponse.json({ error: message }, { status: 500 })
const status = (err as { status?: number }).status === 404 ? 404 : 500
return NextResponse.json({ error: message }, { status })
}
}
+6
View File
@@ -161,6 +161,12 @@ export async function uploadProductImage(
continue
}
if (res.status === 404) {
const err = new Error(`Shopify upload error: 404 — product not found`) as Error & { status: number }
err.status = 404
throw err
}
if (!res.ok) {
const body = await res.text()
throw new Error(`Shopify upload error: ${res.status}${body}`)