用webpack-dev-server开发时代理,决解开发时跨域问题

需要webpack,webpack-dev-server

npm install webapck webpack-dev-server --save-dev

设置时

devServer: {
        historyApiFallback: true,
          hot: true,
        inline: true,
        stats: { colors: true },
        proxy: {
            '/list': {
              target: 'https://api.github.com',
              pathRewrite: {'^/column' : '/column'},
              changeOrigin: true
            }
         }
    },

这段代码就是将  '/list' 通过本地开发服务器webpack-dev-server转发到 'https://api.github.com'

posted @ 2016-10-21 10:32  fengnovo  阅读(11902)  评论(0编辑  收藏  举报