Skip to content

Commit

Permalink
fix: Handle associative array properly for devServer proxy (fix vuejs…
Browse files Browse the repository at this point in the history
  • Loading branch information
Toilal committed Mar 7, 2018
1 parent 179033d commit e063a48
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions packages/@vue/cli-service/lib/util/prepareProxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,9 @@ module.exports = function prepareProxy (proxy, appPublicFolder) {
]
}

// Otherwise, proxy is an object so create an array of proxies to pass to webpackDevServer
return Object.keys(proxy).map(context => {
// Otherwise, proxy is an associative array, so enhance values before passing them to webpackDevServer
const proxies = {}
for (const context in proxy) {
if (!proxy[context].hasOwnProperty('target')) {
console.log(
chalk.red(
Expand All @@ -122,8 +123,9 @@ module.exports = function prepareProxy (proxy, appPublicFolder) {
process.exit(1)
}
const entry = createProxyEntry(proxy[context].target, proxy[context].onProxyReq, context)
return Object.assign({}, defaultConfig, proxy[context], entry)
})
proxies[context] = Object.assign({}, defaultConfig, proxy[context], entry)
}
return proxies
}

function resolveLoopback (proxy) {
Expand Down

0 comments on commit e063a48

Please sign in to comment.