webpack之proxyTable配置

有两种情况:

一,有统一的项目名

config下index.js

配置如下:

    proxyTable: {
      '/tbt_user':{
        target: 'http://47.98.216.251:80', //测试线
        changeOrigin: true, // 是否跨域
        pathRewrite: {
          '^/tbt_user': '/tbt_user'
        }
      }

页面接口调用

    this.$axios.post('/tbt_user/third/pay/query').then((response) => {
      console.log(response)
    }).catch(err => {
      console.log('err')
      console.log(err)
    })

 

二,没有统一项目名

    proxyTable: {
      '/api':{
        target: 'http://47.94.142.215:8082', // 测试
        changeOrigin: true, // 改变源(是否跨域)
        pathRewrite: {
          '^/api': '/'
        }
      }
    }

页面调用:

    this.$axios.post('/api/third/pay/query').then((response) => {
      console.log(response)
    }).catch(err => {
      console.log('err')
      console.log(err)
    })

 

原文链接:https://www.cnblogs.com/wang715100018066/p/10616984.html
本文来源 爱码网,其版权均为 原网址 所有 与本站无关,文章内容系作者个人观点,不代表 本站 对观点赞同或支持。如需转载,请注明文章来源。

© 版权声明

相关文章