vuejs / vue-cli

🛠️ webpack-based tooling for Vue.js Development
https://cli.vuejs.org/
MIT License
29.76k stars 6.33k forks source link

devServer.proxy support array config #2285

Open Astray-git opened 6 years ago

Astray-git commented 6 years ago

What problem does this feature solve?

Passing an Array to devServer.proxy is not supported. It can be used to proxy multiple, specific paths to the same target.

https://webpack.js.org/configuration/dev-server/#devserver-proxy

What does the proposed API look like?

module.exports = {
  //...
  devServer: {
    proxy: [{
      context: ['/auth', '/api'],
      target: 'http://localhost:3000',
    }]
  }
};
alexdilley commented 5 years ago

You can get equivalent functionality via:

{
  proxy: {
    ...['/auth', '/api'].reduce(
      (acc, ctx) => ({
        ...acc,
        [ctx]: { target: 'http://localhost:3000' },
      }),
      {}
    ),
  },
},
lbineau commented 3 years ago

Any update on that issue?