美文网首页
跨域请求之正向代理

跨域请求之正向代理

作者: Mcarrot | 来源:发表于2019-03-08 17:14 被阅读0次

打开config/index.js 修改proxyTable

proxyTable: {

      '/api': {

        target: 'http://121.41.130.58:9090',//设置你调用的接口域名和端口号 别忘了加http

        changeOrigin: true,

        pathRewrite: {

          '^/api': ''//这里理解成用‘/api’代替target里面的地址,后面组件中我们掉接口时直接用api代替 比如我要调用'http://40.00.100.100:3002/user/add',直接写‘/api/user/add’即可

        }

      }

    }

相关文章

网友评论

      本文标题:跨域请求之正向代理

      本文链接:https://www.haomeiwen.com/subject/qmxdpqtx.html