vue.config.js跨域配置,以及代理配置
1 //配置代理后端路径 2 //并设置跨域 3 module.exports = { 4 devServer: { 5 port: 2222, //启用时的端口号 6 proxy: { //代理访问后端接口 7 8 //配置拦截器替换规则 9 '/api' : { //碰到路径中带有/api的路径 就会访问这个代理的地址localhost:9999 10 target: 'http://localhost:9999', //后端代理接口 target: 'http://localhost:9999' 11 ChangeOrigin: true, //是否允许跨域 12 pathRewrite: { 13 '^/api': '' //拦截规则 在路径中碰到/api时,会替换成空字符 14 } 15 } 16 } 17 } 18 }
浙公网安备 33010602011771号