Skip to content
This repository was archived by the owner on Nov 22, 2024. It is now read-only.

Commit 7adc8f9

Browse files
committed
fix(@nguniversal/builders): correctly handle multiple proxies
Closes #2411 (cherry picked from commit ab49471)
1 parent cfe47ff commit 7adc8f9

File tree

1 file changed

+18
-11
lines changed
  • modules/builders/src/ssr-dev-server

1 file changed

+18
-11
lines changed

modules/builders/src/ssr-dev-server/index.ts

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -348,19 +348,26 @@ function getProxyConfig(root: string, proxyConfig: string): browserSync.Middlewa
348348
}
349349

350350
const proxies = Array.isArray(proxySettings) ? proxySettings : [proxySettings];
351-
352-
return proxies.map((proxy) => {
353-
const keys = Object.keys(proxy);
354-
const context = keys[0];
355-
356-
if (keys.length === 1 || typeof context === 'string') {
357-
const normalizedContext = context.replace(/^\*$/, '**').replace(/\/\*$/, '');
358-
359-
return createProxyMiddleware(normalizedContext, proxy[context]) as any;
351+
const createdProxies = [];
352+
353+
for (const proxy of proxies) {
354+
for (const [key, context] of Object.entries(proxy)) {
355+
if (typeof key === 'string') {
356+
createdProxies.push(
357+
createProxyMiddleware(
358+
key.replace(/^\*$/, '**').replace(/\/\*$/, ''),
359+
context as any,
360+
) as browserSync.MiddlewareHandler,
361+
);
362+
} else {
363+
createdProxies.push(
364+
createProxyMiddleware(key, context as any) as browserSync.MiddlewareHandler,
365+
);
366+
}
360367
}
368+
}
361369

362-
return createProxyMiddleware(proxy) as any;
363-
});
370+
return createdProxies;
364371
}
365372

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

0 commit comments

Comments
 (0)