mirror of
https://github.com/R0m1k3/LogiFlow.git
synced 2026-10-18 04:37:19 +02:00
Update webhook integration to use JSON instead of form-data
Removes the use of the `form-data` package and modifies the webhook payload to send data as JSON. Replit-Commit-Author: Agent Replit-Commit-Session-Id: cfbfe47c-0c9a-4ebf-8a41-2937407eccff Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/1957c339-2757-4d1f-8e92-e9f71a1ce58e/cfbfe47c-0c9a-4ebf-8a41-2937407eccff/uD8abDf
This commit is contained in:
1 parent
4247e2d218
commit
c000067327
5 files changed
+18
-33
No files matched your search
+17
-19
@@ -128,24 +128,20 @@ export async function registerRoutes(app: Express): Promise<Server> {
|
||||
userId: user.id
|
||||
});
|
||||
|
||||
// Créer FormData pour l'envoi vers n8n
|
||||
let FormData;
|
||||
try {
|
||||
FormData = (await import('form-data')).default;
|
||||
console.log('✅ BAP: form-data imported successfully');
|
||||
} catch (error) {
|
||||
console.error('❌ BAP: Erreur import form-data:', error);
|
||||
return res.status(500).json({ error: 'Erreur configuration serveur (form-data)' });
|
||||
}
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append('pdf', fileBuffer, {
|
||||
filename: fileName,
|
||||
// Préparer les données JSON pour le webhook n8n (sans form-data)
|
||||
const webhookPayload = {
|
||||
recipient: recipient,
|
||||
fileName: fileName,
|
||||
fileSize: fileBuffer.length,
|
||||
pdfBase64: pdfBase64, // On renvoie le base64 directement
|
||||
contentType: 'application/pdf'
|
||||
};
|
||||
|
||||
console.log('✅ BAP: Payload JSON préparé', {
|
||||
recipient,
|
||||
fileName,
|
||||
fileSize: fileBuffer.length
|
||||
});
|
||||
formData.append('recipient', recipient);
|
||||
|
||||
console.log('✅ BAP: FormData créé avec succès');
|
||||
|
||||
// Envoyer vers le webhook n8n
|
||||
const webhookUrl = 'https://workflow.ffnancy.fr/webhook/a3d03176-b72f-412d-8fb9-f920b9fbab4d';
|
||||
@@ -157,9 +153,11 @@ export async function registerRoutes(app: Express): Promise<Server> {
|
||||
|
||||
const response = await fetch(webhookUrl, {
|
||||
method: 'POST',
|
||||
body: formData,
|
||||
signal: controller.signal,
|
||||
headers: formData.getHeaders()
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(webhookPayload),
|
||||
signal: controller.signal
|
||||
});
|
||||
|
||||
clearTimeout(timeoutId);
|
||||
|
||||
Reference in new issue
Block a user