Skip to content

Commit 7fb9ada

Browse files
author
北灼
committed
fix: devServer proxy config should support array type
1 parent ea4c98a commit 7fb9ada

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

Diff for: packages/@vue/cli-service/lib/util/prepareProxy.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ module.exports = function prepareProxy (proxy, appPublicFolder) {
2727
if (!proxy) {
2828
return undefined
2929
}
30-
if (Array.isArray(proxy) || (typeof proxy !== 'object' && typeof proxy !== 'string')) {
30+
if (typeof proxy !== 'object' && typeof proxy !== 'string') {
3131
console.log(
3232
chalk.red(
3333
'When specified, "proxy" in package.json must be a string or an object.'
@@ -117,6 +117,14 @@ module.exports = function prepareProxy (proxy, appPublicFolder) {
117117
]
118118
}
119119

120+
// Support proxy as an array
121+
if (Array.isArray(proxy)) {
122+
return proxy.map(item => {
123+
if (typeof item === 'function') return item
124+
return Object.assign({}, defaultConfig, item)
125+
})
126+
}
127+
120128
// Otherwise, proxy is an object so create an array of proxies to pass to webpackDevServer
121129
return Object.keys(proxy).map(context => {
122130
const config = proxy[context]

0 commit comments

Comments
 (0)