Skip to content

Commit

Permalink
fix: 代理插件兼容 array 写法 (#260)
Browse files Browse the repository at this point in the history
  • Loading branch information
winixt authored Nov 27, 2024
1 parent b1ea675 commit 7c01ee9
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,15 @@ const ASSET_EXT_NAMES = ['.ico', '.png', '.jpg', '.jpeg', '.gif', '.svg'];
function proxyMiddleware(api) {
return (req, res, next) => {
const proxyConfig = api.config.proxy;
if (proxyConfig && Object.keys(proxyConfig).some(path => req.url.startsWith(path))) {
return next();
if (proxyConfig) {
if (Array.isArray(proxyConfig)) {
if (proxyConfig.some(item => item.context.some(path => path && req.url.startsWith(path)))) {
return next();
}
}
else if (Object.keys(proxyConfig).some(path => req.url.startsWith(path))) {
return next();
}
}
if (ASSET_EXT_NAMES.includes(extname(req.url))) {
return next();
Expand Down

0 comments on commit 7c01ee9

Please sign in to comment.