From be628d726ceec72ff9655cee8f800c68fced8add Mon Sep 17 00:00:00 2001 From: Guy Harwood Date: Thu, 24 Oct 2024 09:42:33 +0100 Subject: [PATCH] Bug/65517 axios requests failing to talk to azure functions API (#2937) * default to ipv4 * configure ipv4 globally for axios --------- Co-authored-by: Mohsen Qureshi --- admin/app.js | 4 ++++ admin/package.json | 2 +- .../services/data-access/sync-results-resync.data.service.js | 4 ++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/admin/app.js b/admin/app.js index d316b25cc5..b873e019ff 100644 --- a/admin/app.js +++ b/admin/app.js @@ -131,6 +131,10 @@ const pupilStatus = require('./routes/pupil-status') const websiteOffline = require('./routes/website-offline') const techSupport = require('./routes/tech-support') const roles = require('./lib/consts/roles') +// globally configure ipv4 for all axios request uses... +const axios = require('axios') +const http = require('http') +axios.defaults.httpAgent = new http.Agent({ family: 4 }) setupBrowserSecurity(app) diff --git a/admin/package.json b/admin/package.json index 6cf2867540..6b4e3a5365 100644 --- a/admin/package.json +++ b/admin/package.json @@ -32,7 +32,7 @@ "watch:integration": "yarn jest --watch --coverage=no --config ./tests-integration/jest.integration.config.js" }, "mtc": { - "assets-version": "6a569a48061e8e7844eee749fb4527b3" + "assets-version": "5eb463baa90e81b0b79de4acfc4a8096" }, "engines": { "node": ">= 18" diff --git a/admin/services/data-access/sync-results-resync.data.service.js b/admin/services/data-access/sync-results-resync.data.service.js index aff8198830..8d207d20b0 100644 --- a/admin/services/data-access/sync-results-resync.data.service.js +++ b/admin/services/data-access/sync-results-resync.data.service.js @@ -2,8 +2,8 @@ const sqlService = require('./sql.service') const R = require('ramda') -const axios = require('axios') const config = require('../../config') +const axios = require('axios') const functionUrl = `${config.Functions.Throttled.BaseAdminUrl}/sync-results-init` const requestConfig = { @@ -32,7 +32,7 @@ const service = { }, callSyncResultsInitFunction: async function callSyncResultsInitFunction (message) { - const response = await axios.post(functionUrl, { input: JSON.stringify(message) }, requestConfig) + const response = await axios.post(functionUrl, message, requestConfig) if (response.status !== 202) { throw new Error(`request to ${functionUrl} failed: ${response.status} - ${response.statusText}`) }