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)
    })

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM