mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-14 10:49:10 +02:00
Improve invoice sending by proxying requests through the backend
Introduces a new backend API endpoint to proxy invoice sending requests, resolving CORS issues and enhancing error handling. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 1e4433b5-47ab-464c-b663-fea2e53367dd Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Event-Id: df58cf24-9a7e-4197-bdbe-786d56d0c35e 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:
1 parent
e3785d4457
commit
ca576dc289
3 files changed
+87
-9
No files matched your search
@@ -515,24 +515,21 @@ 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');
|
||||
|
||||
// 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, {
|
||||
// Envoyer via route backend proxy (résout problèmes CORS)
|
||||
const response = await fetch('/api/reconciliation/send-invoice', {
|
||||
method: 'POST',
|
||||
body: formData,
|
||||
signal: controller.signal,
|
||||
credentials: 'include'
|
||||
});
|
||||
|
||||
clearTimeout(timeoutId);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`Erreur ${response.status}: ${response.statusText}`);
|
||||
const errorData = await response.json().catch(() => ({ error: 'Erreur inconnue' }));
|
||||
throw new Error(errorData.error || `Erreur ${response.status}`);
|
||||
}
|
||||
|
||||
handleCloseWaitingModal();
|
||||
|
||||
Reference in new issue
Block a user