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 }

 

posted on 2023-05-21 17:42  你就学个JVAV?  阅读(582)  评论(0)    收藏  举报

导航