diff --git a/package.json b/package.json index 0727a05914..7df508f3dd 100644 --- a/package.json +++ b/package.json @@ -152,7 +152,7 @@ "date-fns-tz": "^2.0.0", "express": "~4.20", "glob": "<9", - "http-proxy-middleware": "<1", + "http-proxy-middleware": "<3", "ignore-styles": "~5.0", "jest-image-snapshot": "^6", "jest-puppeteer": "^5", diff --git a/src/setupProxy.js b/src/setupProxy.js index 2899dbb355..e53dc12c4b 100644 --- a/src/setupProxy.js +++ b/src/setupProxy.js @@ -4,7 +4,7 @@ const url = require('url'); const fs = require('fs'); const path = require('path'); -const proxy = require('http-proxy-middleware'); +const {createProxyMiddleware} = require('http-proxy-middleware'); const { SKIP_OS_WEB_PROXY, FIXTURES, @@ -130,7 +130,7 @@ function setupTestProxy(app) { } function archiveProxy(app) { - archivePaths.forEach(path => app.use(proxy(path, { + archivePaths.forEach(path => app.use(createProxyMiddleware(path, { target: `${ARCHIVE_URL}${path}`, prependPath: false, changeOrigin: true, @@ -138,7 +138,7 @@ function archiveProxy(app) { } function accountsProxy(app) { - app.use(proxy(REACT_APP_ACCOUNTS_URL, { + app.use(createProxyMiddleware(REACT_APP_ACCOUNTS_URL, { target: ACCOUNTS_URL, changeOrigin: true, autoRewrite: true, @@ -153,7 +153,7 @@ function accountsProxy(app) { } function imageCdnProxy(app) { - app.use(proxy(REACT_APP_IMAGE_CDN_URL, { + app.use(createProxyMiddleware(REACT_APP_IMAGE_CDN_URL, { target: IMAGE_CDN_URL, changeOrigin: true, autoRewrite: true, @@ -161,7 +161,7 @@ function imageCdnProxy(app) { } function searchProxy(app) { - app.use(proxy(REACT_APP_SEARCH_URL, { + app.use(createProxyMiddleware(REACT_APP_SEARCH_URL, { target: SEARCH_URL, changeOrigin: true, autoRewrite: true, @@ -169,7 +169,7 @@ function searchProxy(app) { } function highlightsProxy(app) { - app.use(proxy(REACT_APP_HIGHLIGHTS_URL, { + app.use(createProxyMiddleware(REACT_APP_HIGHLIGHTS_URL, { target: HIGHLIGHTS_URL, changeOrigin: true, autoRewrite: true, @@ -177,14 +177,14 @@ function highlightsProxy(app) { } function osWebApiProxy(app) { - app.use(proxy(REACT_APP_OS_WEB_API_URL, { + app.use(createProxyMiddleware(REACT_APP_OS_WEB_API_URL, { target: OS_WEB_URL, changeOrigin: true, })); } function osWebProxy(app) { - app.use(proxy((path) => !path.match(/^\/((books\/.*)|(apps\/rex\/.*)|static.*|errors.*|rex.*|asset-manifest.json|precache-manifest.*|index.html|\/)?$/) , { + app.use(createProxyMiddleware((path) => !path.match(/^\/((books\/.*)|(apps\/rex\/.*)|static.*|errors.*|rex.*|asset-manifest.json|precache-manifest.*|index.html|\/)?$/) , { target: OS_WEB_URL, changeOrigin: true, })); diff --git a/yarn.lock b/yarn.lock index f08362b420..dfffb9ac3e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6486,10 +6486,10 @@ resolved "https://registry.yarnpkg.com/@types/http-errors/-/http-errors-2.0.1.tgz#20172f9578b225f6c7da63446f56d4ce108d5a65" integrity sha512-/K3ds8TRAfBvi5vfjuz8y6+GiAYBZ0x4tXv1Av6CWBWn0IlADc+ZX9pMq7oU0fNQPnBwIZl3rmeLp6SBApbxSQ== -"@types/http-proxy@^1.17.3": - version "1.17.10" - resolved "https://registry.yarnpkg.com/@types/http-proxy/-/http-proxy-1.17.10.tgz#e576c8e4a0cc5c6a138819025a88e167ebb38d6c" - integrity sha512-Qs5aULi+zV1bwKAg5z1PWnDXWmsn+LxIvUGv6E2+OOMYhclZMO+OXd9pYVf2gLykf2I7IV2u7oTHwChPNsvJ7g== +"@types/http-proxy@^1.17.8": + version "1.17.15" + resolved "https://registry.yarnpkg.com/@types/http-proxy/-/http-proxy-1.17.15.tgz#12118141ce9775a6499ecb4c01d02f90fc839d36" + integrity sha512-25g5atgiVNTIv0LBDTg1H74Hvayx0ajtJPLLcYE3whFv75J0pWNtOBzaXJQgDTmrX1bx5U9YC2w/n65BN1HwRQ== dependencies: "@types/node" "*" @@ -8132,7 +8132,7 @@ braces@^2.3.1, braces@^2.3.2: split-string "^3.0.2" to-regex "^3.0.1" -braces@^3.0.1, braces@^3.0.2, braces@~3.0.2: +braces@^3.0.2, braces@~3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107" integrity sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A== @@ -12229,18 +12229,18 @@ http-proxy-middleware@0.19.1: lodash "^4.17.11" micromatch "^3.1.10" -http-proxy-middleware@<1: - version "0.21.0" - resolved "https://registry.yarnpkg.com/http-proxy-middleware/-/http-proxy-middleware-0.21.0.tgz#c6b1ca05174b5fbc57bee9485ffa0fa2f0dabeb0" - integrity sha512-4Arcl5QQ6pRMRJmtM1WVHKHkFAQn5uvw83XuNeqnMTOikDiCoTxv5/vdudhKQsF+1mtaAawrK2SEB1v2tYecdQ== +http-proxy-middleware@<3: + version "2.0.7" + resolved "https://registry.yarnpkg.com/http-proxy-middleware/-/http-proxy-middleware-2.0.7.tgz#915f236d92ae98ef48278a95dedf17e991936ec6" + integrity sha512-fgVY8AV7qU7z/MmXJ/rxwbrtQH4jBQ9m7kp3llF0liB7glmFeVZFBepQb32T3y8n8k2+AEYuMPCpinYW+/CuRA== dependencies: - "@types/http-proxy" "^1.17.3" - http-proxy "^1.18.0" + "@types/http-proxy" "^1.17.8" + http-proxy "^1.18.1" is-glob "^4.0.1" - lodash "^4.17.15" + is-plain-obj "^3.0.0" micromatch "^4.0.2" -http-proxy@^1.17.0, http-proxy@^1.18.0: +http-proxy@^1.17.0, http-proxy@^1.18.1: version "1.18.1" resolved "https://registry.yarnpkg.com/http-proxy/-/http-proxy-1.18.1.tgz#401541f0534884bbf95260334e72f88ee3976549" integrity sha512-7mz/721AbnJwIVbnaSv1Cz3Am0ZLT/UBwkC92VlxhXv/k/BBQfM2fXElQNC27BVGr0uwUpplYPQM9LnaBMR5NQ== @@ -12841,14 +12841,7 @@ is-glob@^3.1.0: dependencies: is-extglob "^2.1.0" -is-glob@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.0.tgz#9521c76845cc2610a85203ddf080a958c2ffabc0" - integrity sha1-lSHHaEXMJhCoUgPd8ICpWML/q8A= - dependencies: - is-extglob "^2.1.1" - -is-glob@^4.0.1, is-glob@~4.0.1: +is-glob@^4.0.0, is-glob@^4.0.1, is-glob@~4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.1.tgz#7567dbe9f2f5e2467bc77ab83c4a29482407a5dc" integrity sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg== @@ -12933,6 +12926,11 @@ is-plain-obj@^2.0.0: resolved "https://registry.yarnpkg.com/is-plain-obj/-/is-plain-obj-2.1.0.tgz#45e42e37fccf1f40da8e5f76ee21515840c09287" integrity sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA== +is-plain-obj@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/is-plain-obj/-/is-plain-obj-3.0.0.tgz#af6f2ea14ac5a646183a5bbdb5baabbc156ad9d7" + integrity sha512-gwsOE28k+23GP1B6vFl1oVh/WOzmawBrKwo5Ev6wMKzPkaXaCDIQKzLnvsA42DRlbVTWorkgTKIviAKCWkfUwA== + is-plain-object@^2.0.1, is-plain-object@^2.0.3, is-plain-object@^2.0.4: version "2.0.4" resolved "https://registry.yarnpkg.com/is-plain-object/-/is-plain-object-2.0.4.tgz#2c163b3fafb1b606d9d17928f05c2a1c38e07677" @@ -14704,15 +14702,7 @@ micromatch@^3.1.10, micromatch@^3.1.4: snapdragon "^0.8.1" to-regex "^3.0.2" -micromatch@^4.0.2: - version "4.0.4" - resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.4.tgz#896d519dfe9db25fce94ceb7a500919bf881ebf9" - integrity sha512-pRmzw/XUcwXGpD9aI9q/0XOwLNygjETJ8y0ao0wdqprrzDa4YnxLcz7fQRZr8voh8V10kGhABbNcHVk5wHgWwg== - dependencies: - braces "^3.0.1" - picomatch "^2.2.3" - -micromatch@^4.0.4: +micromatch@^4.0.2, micromatch@^4.0.4: version "4.0.5" resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.5.tgz#bc8999a7cbbf77cdc89f132f6e467051b49090c6" integrity sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==