From ab4b1d39130e4d025991920c2e7bf306710d58f3 Mon Sep 17 00:00:00 2001 From: Daniel Baark <5101747+baarkerlounger@users.noreply.github.com> Date: Tue, 5 Nov 2024 11:21:48 +0000 Subject: [PATCH] Bump Http Proxy Middleware, legacy adapter (#7291) --- package-lock.json | 81 +++++++++++++++++--------- package.json | 4 +- src/apps/__export-wins-review/index.js | 4 +- src/middleware/api-proxy.js | 4 +- 4 files changed, 61 insertions(+), 32 deletions(-) diff --git a/package-lock.json b/package-lock.json index e7804c29efc..ad78dd9370a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -47,7 +47,7 @@ "govuk-react": "^0.10.7", "hawk": "^9.0.2", "history": "^4.10.1", - "http-proxy-middleware": "^2.0.4", + "http-proxy-middleware": "^3.0.0", "joi": "^17.13.1", "lodash": "^4.17.21", "markdown-it": "^14.0.0", @@ -7085,7 +7085,7 @@ "version": "1.19.5", "resolved": "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.19.5.tgz", "integrity": "sha512-fB3Zu92ucau0iQ0JMCFQE7b/dv8Ot07NI3KaZIkIUNXq82k4eBAqUaneXfleGY9JWskeS9y+u0nXMyspcuQrCg==", - "devOptional": true, + "dev": true, "dependencies": { "@types/connect": "*", "@types/node": "*" @@ -7185,7 +7185,7 @@ "version": "4.17.21", "resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.21.tgz", "integrity": "sha512-ejlPM315qwLpaQlQDTjPdsUFSc6ZsP4AN6AlWnogPjQ7CVi7PYF3YVz+CY3jE2pwYf7E/7HlDAN0rV2GxTG0HQ==", - "devOptional": true, + "dev": true, "dependencies": { "@types/body-parser": "*", "@types/express-serve-static-core": "^4.17.33", @@ -7197,7 +7197,7 @@ "version": "4.19.5", "resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-4.19.5.tgz", "integrity": "sha512-y6W03tvrACO72aijJ5uF02FRq5cgDR9lUxddQ8vyF+GvmjJQqbzDcJngEjURc+ZsG31VI3hODNZJ2URj86pzmg==", - "devOptional": true, + "dev": true, "dependencies": { "@types/node": "*", "@types/qs": "*", @@ -7233,7 +7233,7 @@ "version": "2.0.4", "resolved": "https://registry.npmjs.org/@types/http-errors/-/http-errors-2.0.4.tgz", "integrity": "sha512-D0CFMMtydbJAegzOyHjtiKPLlvnm3iTZyZRSZoLq2mRhDdmLfIWOCYPfQJ4cu2erKghU++QvjcUjp/5h7hESpA==", - "devOptional": true + "dev": true }, "node_modules/@types/http-proxy": { "version": "1.17.15", @@ -7277,7 +7277,7 @@ "version": "1.3.5", "resolved": "https://registry.npmjs.org/@types/mime/-/mime-1.3.5.tgz", "integrity": "sha512-/pyBZWSLD2n0dcHE3hq8s8ZvcETHtEuF+3E7XVt0Ig2nvsVQXdghHVcEkIWjy9A0wKfTn97a/PSDYohKIlnP/w==", - "devOptional": true + "dev": true }, "node_modules/@types/minimatch": { "version": "5.1.2", @@ -7348,13 +7348,13 @@ "version": "6.9.15", "resolved": "https://registry.npmjs.org/@types/qs/-/qs-6.9.15.tgz", "integrity": "sha512-uXHQKES6DQKKCLh441Xv/dwxOq1TVS3JPUMlEqoEglvlhR6Mxnlew/Xq/LRVHpLyk7iK3zODe1qYHIMltO7XGg==", - "devOptional": true + "dev": true }, "node_modules/@types/range-parser": { "version": "1.2.7", "resolved": "https://registry.npmjs.org/@types/range-parser/-/range-parser-1.2.7.tgz", "integrity": "sha512-hKormJbkJqzQGhziax5PItDUTMAM9uE2XXQmM37dyd4hVM+5aVl7oVxMVUiVQn2oCQFN/LKCZdvSM0pFRqbSmQ==", - "devOptional": true + "dev": true }, "node_modules/@types/react": { "version": "18.3.5", @@ -7388,7 +7388,7 @@ "version": "0.17.4", "resolved": "https://registry.npmjs.org/@types/send/-/send-0.17.4.tgz", "integrity": "sha512-x2EM6TJOybec7c52BX0ZspPodMsQUd5L6PRwOunVyVUhXiBSKf3AezDL8Dgvgt5o0UfKNfuA0eMLr2wLT4AiBA==", - "devOptional": true, + "dev": true, "dependencies": { "@types/mime": "^1", "@types/node": "*" @@ -7407,7 +7407,7 @@ "version": "1.15.7", "resolved": "https://registry.npmjs.org/@types/serve-static/-/serve-static-1.15.7.tgz", "integrity": "sha512-W8Ym+h8nhuRwaKPaDw34QUkwsGi6Rc4yYqvKFo5rm2FUEhCFbzVWrxXUxuKK8TASjWsysJY0nsmNCGhCOIsrOw==", - "devOptional": true, + "dev": true, "dependencies": { "@types/http-errors": "*", "@types/node": "*", @@ -14282,26 +14282,20 @@ } }, "node_modules/http-proxy-middleware": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/http-proxy-middleware/-/http-proxy-middleware-2.0.6.tgz", - "integrity": "sha512-ya/UeJ6HVBYxrgYotAZo1KvPWlgB48kUJLDePFeneHsVujFaW5WNj2NgWCAE//B1Dl02BIfYlpNgBy8Kf8Rjmw==", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/http-proxy-middleware/-/http-proxy-middleware-3.0.3.tgz", + "integrity": "sha512-usY0HG5nyDUwtqpiZdETNbmKtw3QQ1jwYFZ9wi5iHzX2BcILwQKtYDJPo7XHTsu5Z0B2Hj3W9NNnbd+AjFWjqg==", + "license": "MIT", "dependencies": { - "@types/http-proxy": "^1.17.8", + "@types/http-proxy": "^1.17.15", + "debug": "^4.3.6", "http-proxy": "^1.18.1", - "is-glob": "^4.0.1", - "is-plain-obj": "^3.0.0", - "micromatch": "^4.0.2" + "is-glob": "^4.0.3", + "is-plain-object": "^5.0.0", + "micromatch": "^4.0.8" }, "engines": { - "node": ">=12.0.0" - }, - "peerDependencies": { - "@types/express": "^4.17.13" - }, - "peerDependenciesMeta": { - "@types/express": { - "optional": true - } + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, "node_modules/http-server": { @@ -15132,6 +15126,8 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-3.0.0.tgz", "integrity": "sha512-gwsOE28k+23GP1B6vFl1oVh/WOzmawBrKwo5Ev6wMKzPkaXaCDIQKzLnvsA42DRlbVTWorkgTKIviAKCWkfUwA==", + "dev": true, + "license": "MIT", "engines": { "node": ">=10" }, @@ -15139,6 +15135,14 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/is-plain-object": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-5.0.0.tgz", + "integrity": "sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q==", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/is-potential-custom-element-name": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/is-potential-custom-element-name/-/is-potential-custom-element-name-1.0.1.tgz", @@ -25477,6 +25481,31 @@ } } }, + "node_modules/webpack-dev-server/node_modules/http-proxy-middleware": { + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/http-proxy-middleware/-/http-proxy-middleware-2.0.7.tgz", + "integrity": "sha512-fgVY8AV7qU7z/MmXJ/rxwbrtQH4jBQ9m7kp3llF0liB7glmFeVZFBepQb32T3y8n8k2+AEYuMPCpinYW+/CuRA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/http-proxy": "^1.17.8", + "http-proxy": "^1.18.1", + "is-glob": "^4.0.1", + "is-plain-obj": "^3.0.0", + "micromatch": "^4.0.2" + }, + "engines": { + "node": ">=12.0.0" + }, + "peerDependencies": { + "@types/express": "^4.17.13" + }, + "peerDependenciesMeta": { + "@types/express": { + "optional": true + } + } + }, "node_modules/webpack-dev-server/node_modules/ipaddr.js": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-2.2.0.tgz", diff --git a/package.json b/package.json index 54d8ad1ff58..57752522b88 100644 --- a/package.json +++ b/package.json @@ -102,7 +102,7 @@ "govuk-react": "^0.10.7", "hawk": "^9.0.2", "history": "^4.10.1", - "http-proxy-middleware": "^2.0.4", + "http-proxy-middleware": "^3.0.0", "joi": "^17.13.1", "lodash": "^4.17.21", "markdown-it": "^14.0.0", @@ -226,4 +226,4 @@ "tough-cookie": "4.1.3", "jsonpath-plus": "10.0.0" } -} +} \ No newline at end of file diff --git a/src/apps/__export-wins-review/index.js b/src/apps/__export-wins-review/index.js index da649554319..e5306549bc4 100644 --- a/src/apps/__export-wins-review/index.js +++ b/src/apps/__export-wins-review/index.js @@ -1,4 +1,4 @@ -const { createProxyMiddleware } = require('http-proxy-middleware') +const { legacyCreateProxyMiddleware } = require('http-proxy-middleware') const config = require('../../config') @@ -7,7 +7,7 @@ module.exports = (app) => { // any other authorization and we don't want any cookie to be set app.use( '/api-proxy/v4/export-win/review/', - createProxyMiddleware({ + legacyCreateProxyMiddleware({ target: config.apiRoot, changeOrigin: true, pathRewrite: { diff --git a/src/middleware/api-proxy.js b/src/middleware/api-proxy.js index ae5baf6641e..3366ce828b3 100644 --- a/src/middleware/api-proxy.js +++ b/src/middleware/api-proxy.js @@ -1,4 +1,4 @@ -const { createProxyMiddleware } = require('http-proxy-middleware') +const { legacyCreateProxyMiddleware } = require('http-proxy-middleware') const config = require('../config') const getZipkinHeaders = require('../lib/get-zipkin-headers') @@ -95,7 +95,7 @@ const ALLOWLIST = [ module.exports = (app) => { app.use( ALLOWLIST.map((apiPath) => API_PROXY_PATH + apiPath), - createProxyMiddleware('/', { + legacyCreateProxyMiddleware('/', { changeOrigin: true, target: config.apiRoot, pathRewrite: {