vue + webpack
构建的项目解决浏览器跨域问题
在 config/index.js
中配置 proxyTable
代理,如下图所示:
proxyTable: { // 配置代理 '/api': { // 匹配所有以 '/api' 开头的请求路径 target: 'http://localhost:4000', // 代理目标的基础路径 changeOrigin: true, // 支持跨域 pathRewrite: { // 重写路径: 去掉路径中开头的'/api' '^/api': '' } }},