Skip to content
This repository was archived by the owner on Nov 22, 2024. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 18 additions & 11 deletions modules/builders/src/ssr-dev-server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -348,19 +348,26 @@ function getProxyConfig(root: string, proxyConfig: string): browserSync.Middlewa
}

const proxies = Array.isArray(proxySettings) ? proxySettings : [proxySettings];

return proxies.map((proxy) => {
const keys = Object.keys(proxy);
const context = keys[0];

if (keys.length === 1 || typeof context === 'string') {
const normalizedContext = context.replace(/^\*$/, '**').replace(/\/\*$/, '');

return createProxyMiddleware(normalizedContext, proxy[context]) as any;
const createdProxies = [];

for (const proxy of proxies) {
for (const [key, context] of Object.entries(proxy)) {
if (typeof key === 'string') {
createdProxies.push(
createProxyMiddleware(
key.replace(/^\*$/, '**').replace(/\/\*$/, ''),
context as any,
) as browserSync.MiddlewareHandler,
);
} else {
createdProxies.push(
createProxyMiddleware(key, context as any) as browserSync.MiddlewareHandler,
);
}
}
}

return createProxyMiddleware(proxy) as any;
});
return createdProxies;
}

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