码迷,mamicode.com
首页 > 其他好文 > 详细

vue中调接口跨域问题,采用proxyTable同时调用不同服务器接口,404

时间:2019-10-17 21:45:52      阅读:132      评论:0      收藏:0      [点我收藏+]

标签:target   重写   vue   跨域问题   http   path   origin   端口号   简单   

之前报错跨域,然后选择在config/index.js中配置proxyTable解决跨域问题

proxyTable: {       //配置反向代理
      ‘/api‘:{
        target:‘http://XXS‘,    //设置你调用的接口域名和端口号
        changeOrigin:true, //是否跨域
        pathRewrite:{ //是否重写地址。可简单理解为在target后面加上。。。/把target换成。。。。
          ‘^/api‘:‘http://XXS‘/
        }
      },
      
      ‘/chibi‘: {
        target: ‘http://XXX‘,//设置你调用的接口域名和端口号 
        changeOrigin: true,
        pathRewrite: {
          ‘^/chibi‘: ‘‘
        }
      }
    }

 之前一直薄脆404,是重写部分写错了,在重写部分加上了/chibi,请求时地址自动变为

http://XXX/chibi...

 

vue中调接口跨域问题,采用proxyTable同时调用不同服务器接口,404

标签:target   重写   vue   跨域问题   http   path   origin   端口号   简单   

原文地址:https://www.cnblogs.com/lian-dong/p/11695248.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!