Update invoice sending to directly use webhook URL and add timeout

Replaced the backend proxy route for sending invoices with a direct fetch to the webhook URL, incorporating a 60-second timeout using AbortController. Also added 'busboy' and '@types/busboy' to package.json.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 1e4433b5-47ab-464c-b663-fea2e53367dd
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Event-Id: ca0ae43e-5b56-4b02-8cb5-0e76adf608ba
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/1957c339-2757-4d1f-8e92-e9f71a1ce58e/1e4433b5-47ab-464c-b663-fea2e53367dd/qOJ89TE
This commit is contained in:
michaelschal committed 2025-11-04 15:21:16 +00:00
1 parent 89211e4f28
commit e3785d4457
4 files changed
+23 -101

No files matched your search

+10 -9
View File
@@ -515,24 +515,25 @@ export default function BLReconciliation() {
try {
const formData = new FormData();
formData.append('file', selectedFile);
formData.append('webhookUrl', selectedDeliveryForInvoice.group.webhookUrl);
formData.append('supplier', selectedDeliveryForInvoice.supplier?.name || '');
formData.append('blNumber', selectedDeliveryForInvoice.blNumber || '');
formData.append('type', 'Facture');
// Envoyer via notre route backend proxy (évite problèmes CORS et erreurs webhook)
const response = await fetch('/api/reconciliation/send-invoice', {
// Créer un AbortController pour gérer le timeout
const controller = new AbortController();
const timeoutId = setTimeout(() => controller.abort(), 60000); // 60 secondes
const response = await fetch(selectedDeliveryForInvoice.group.webhookUrl, {
method: 'POST',
body: formData,
credentials: 'include' // Important pour l'authentification
signal: controller.signal,
});
if (!response.ok) {
const errorData = await response.json().catch(() => ({}));
throw new Error(errorData.error || `Erreur ${response.status}: ${response.statusText}`);
}
clearTimeout(timeoutId);
const result = await response.json();
if (!response.ok) {
throw new Error(`Erreur ${response.status}: ${response.statusText}`);
}
handleCloseWaitingModal();