From fb17e2fb5e6e4d5c14f0e4683300c6cd806679e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?No=C3=A9=20TATOUD?= Date: Wed, 15 May 2024 14:00:21 +0200 Subject: [PATCH] feat: add user agent to dsc requests --- packages/server/esp/dsc/dscProvider.js | 19 ++++++++++++++++--- packages/server/node.config.js | 1 + 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/packages/server/esp/dsc/dscProvider.js b/packages/server/esp/dsc/dscProvider.js index 050180b1..c389f4e0 100644 --- a/packages/server/esp/dsc/dscProvider.js +++ b/packages/server/esp/dsc/dscProvider.js @@ -14,7 +14,11 @@ class DscProvider { async connectApiCall() { return axios.get(`${config.dscUrl}`, { - headers: { apiKey: this.apiKey, 'Content-Type': 'application/json' }, + headers: { + apiKey: this.apiKey, + 'Content-Type': 'application/json', + 'User-Agent': config.dscUserAgent, + }, }); } @@ -49,6 +53,7 @@ class DscProvider { headers: { apiKey: this.apiKey, 'Content-Type': 'application/json', + 'User-Agent': config.dscUserAgent, }, }); } @@ -57,7 +62,11 @@ class DscProvider { const url = `${config.dscUrl}/withTypeCampagne`; try { return await axios.post(url, restData, { - headers: { apiKey: this.apiKey, 'Content-Type': 'application/json' }, + headers: { + apiKey: this.apiKey, + 'Content-Type': 'application/json', + 'User-Agent': config.dscUserAgent, + }, params: { typeCampagne }, }); } catch (error) { @@ -69,7 +78,11 @@ class DscProvider { const url = `${config.dscUrl}/withTypeCampagne/${campaignMailId}`; try { return await axios.put(url, restData, { - headers: { apiKey: this.apiKey, 'Content-Type': 'application/json' }, + headers: { + apiKey: this.apiKey, + 'Content-Type': 'application/json', + 'User-Agent': config.dscUserAgent, + }, params: { typeCampagne }, }); } catch (error) { diff --git a/packages/server/node.config.js b/packages/server/node.config.js index f22e760c..45c05c4a 100644 --- a/packages/server/node.config.js +++ b/packages/server/node.config.js @@ -61,6 +61,7 @@ const config = rc('lepatron', { }, proxyUrl: process.env.QUOTAGUARDSTATIC_URL, dscUrl: process.env.DSC_ESP_URL, + dscUserAgent: process.env.DSC_USER_AGENT, NODE_ENV: process.env.NODE_ENV, });