Skip to content

Commit 733fba2

Browse files
committed
build: update dependency http-proxy-middleware to v3
1 parent d482c65 commit 733fba2

File tree

6 files changed

+51
-46
lines changed

6 files changed

+51
-46
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@
141141
"express": "4.19.2",
142142
"fast-glob": "3.3.2",
143143
"http-proxy": "^1.18.1",
144-
"http-proxy-middleware": "2.0.6",
144+
"http-proxy-middleware": "3.0.0",
145145
"https-proxy-agent": "7.0.4",
146146
"husky": "9.0.11",
147147
"ini": "4.1.2",

packages/angular_devkit/build_angular/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"esbuild-wasm": "0.20.2",
3434
"fast-glob": "3.3.2",
3535
"https-proxy-agent": "7.0.4",
36-
"http-proxy-middleware": "2.0.6",
36+
"http-proxy-middleware": "3.0.0",
3737
"inquirer": "9.2.17",
3838
"jsonc-parser": "3.2.1",
3939
"karma-source-map-support": "1.4.0",

packages/angular_devkit/build_angular/src/builders/dev-server/vite-server.ts

-1
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,6 @@ export async function setupServer(
451451
const proxy = await loadProxyConfiguration(
452452
serverOptions.workspaceRoot,
453453
serverOptions.proxyConfig,
454-
true,
455454
);
456455

457456
// dynamically import Vite for ESM compatibility

packages/angular_devkit/build_angular/src/builders/ssr-dev-server/index.ts

+33-34
Original file line numberDiff line numberDiff line change
@@ -306,21 +306,25 @@ async function initBrowserSync(
306306
const { createProxyMiddleware } = await import('http-proxy-middleware');
307307

308308
// Remove leading slash
309-
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
310-
(bsOptions.scriptPath = (p) => p.substring(1)),
311-
(bsOptions.middleware = [
312-
createProxyMiddleware(defaultSocketIoPath, {
313-
target: url.format({
314-
protocol: 'http',
315-
hostname: host,
316-
port: bsPort,
317-
pathname: path,
318-
}),
319-
ws: true,
320-
logLevel: 'silent',
321-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
322-
}) as any,
323-
]);
309+
bsOptions.scriptPath = (p) => p.substring(1);
310+
311+
bsOptions.middleware = [
312+
createProxyMiddleware({
313+
pathFilter: defaultSocketIoPath,
314+
target: url.format({
315+
protocol: 'http',
316+
hostname: host,
317+
port: bsPort,
318+
pathname: path,
319+
}),
320+
ws: true,
321+
logger: {
322+
info: () => {},
323+
warn: () => {},
324+
error: () => {},
325+
},
326+
}),
327+
];
324328
}
325329
}
326330

@@ -376,27 +380,22 @@ function getSslConfig(
376380
}
377381

378382
async function getProxyConfig(root: string, proxyConfig: string): Promise<MiddlewareHandler[]> {
379-
const proxy = await loadProxyConfiguration(root, proxyConfig, false);
380-
const createdProxies = [];
381-
const { createProxyMiddleware } = await import('http-proxy-middleware');
382-
for (const [key, context] of Object.entries(proxy)) {
383-
if (typeof key === 'string') {
384-
createdProxies.push(
385-
createProxyMiddleware(
386-
key.replace(/^\*$/, '**').replace(/\/\*$/, ''),
387-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
388-
context as any,
389-
) as MiddlewareHandler,
390-
);
391-
} else {
392-
createdProxies.push(
393-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
394-
createProxyMiddleware(key, context as any) as MiddlewareHandler,
395-
);
396-
}
383+
const proxy = await loadProxyConfiguration(root, proxyConfig);
384+
if (!proxy) {
385+
return [];
397386
}
398387

399-
return createdProxies;
388+
const { createProxyMiddleware } = await import('http-proxy-middleware');
389+
390+
return Object.entries(proxy).map(([key, context]) => {
391+
const filterRegExp = new RegExp(key);
392+
393+
return createProxyMiddleware({
394+
pathFilter: (pathname) => filterRegExp.test(pathname),
395+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
396+
...(context as any),
397+
});
398+
});
400399
}
401400

402401
export default createBuilder<SSRDevServerBuilderOptions, BuilderOutput>(execute);

packages/angular_devkit/build_angular/src/utils/load-proxy-config.ts

+2-7
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ import { loadEsmModule } from './load-esm';
1818
export async function loadProxyConfiguration(
1919
root: string,
2020
proxyConfig: string | undefined,
21-
normalize = false,
22-
) {
21+
): Promise<Record<string, object> | undefined> {
2322
if (!proxyConfig) {
2423
return undefined;
2524
}
@@ -81,11 +80,7 @@ export async function loadProxyConfiguration(
8180
}
8281
}
8382

84-
if (normalize) {
85-
proxyConfiguration = normalizeProxyConfiguration(proxyConfiguration);
86-
}
87-
88-
return proxyConfiguration;
83+
return normalizeProxyConfiguration(proxyConfiguration);
8984
}
9085

9186
/**

yarn.lock

+14-2
Original file line numberDiff line numberDiff line change
@@ -3700,7 +3700,7 @@
37003700
resolved "https://registry.yarnpkg.com/@types/http-errors/-/http-errors-2.0.4.tgz#7eb47726c391b7345a6ec35ad7f4de469cf5ba4f"
37013701
integrity sha512-D0CFMMtydbJAegzOyHjtiKPLlvnm3iTZyZRSZoLq2mRhDdmLfIWOCYPfQJ4cu2erKghU++QvjcUjp/5h7hESpA==
37023702

3703-
"@types/http-proxy@^1.17.4", "@types/http-proxy@^1.17.8":
3703+
"@types/http-proxy@^1.17.10", "@types/http-proxy@^1.17.4", "@types/http-proxy@^1.17.8":
37043704
version "1.17.14"
37053705
resolved "https://registry.yarnpkg.com/@types/http-proxy/-/http-proxy-1.17.14.tgz#57f8ccaa1c1c3780644f8a94f9c6b5000b5e2eec"
37063706
integrity sha512-SSrD0c1OQzlFX7pGu1eXxSEjemej64aaNPRhhVYUGqXh0BtldAAx37MG8btcumvpgKyZp1F5Gn3JkktdxiFv6w==
@@ -8187,6 +8187,18 @@ http-proxy-middleware@2.0.6, http-proxy-middleware@^2.0.3:
81878187
is-plain-obj "^3.0.0"
81888188
micromatch "^4.0.2"
81898189

8190+
http-proxy-middleware@3.0.0:
8191+
version "3.0.0"
8192+
resolved "https://registry.yarnpkg.com/http-proxy-middleware/-/http-proxy-middleware-3.0.0.tgz#550790357d6f92a9b82ab2d63e07343a791cf26b"
8193+
integrity sha512-36AV1fIaI2cWRzHo+rbcxhe3M3jUDCNzc4D5zRl57sEWRAxdXYtw7FSQKYY6PDKssiAKjLYypbssHk+xs/kMXw==
8194+
dependencies:
8195+
"@types/http-proxy" "^1.17.10"
8196+
debug "^4.3.4"
8197+
http-proxy "^1.18.1"
8198+
is-glob "^4.0.1"
8199+
is-plain-obj "^3.0.0"
8200+
micromatch "^4.0.5"
8201+
81908202
http-proxy@^1.18.1:
81918203
version "1.18.1"
81928204
resolved "https://registry.yarnpkg.com/http-proxy/-/http-proxy-1.18.1.tgz#401541f0534884bbf95260334e72f88ee3976549"
@@ -9904,7 +9916,7 @@ methods@~1.1.2:
99049916
resolved "https://registry.yarnpkg.com/methods/-/methods-1.1.2.tgz#5529a4d67654134edcc5266656835b0f851afcee"
99059917
integrity sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==
99069918

9907-
micromatch@^4.0.2, micromatch@^4.0.4:
9919+
micromatch@^4.0.2, micromatch@^4.0.4, micromatch@^4.0.5:
99089920
version "4.0.5"
99099921
resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.5.tgz#bc8999a7cbbf77cdc89f132f6e467051b49090c6"
99109922
integrity sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==

0 commit comments

Comments
 (0)