webpack之proxyTable配置

webpack之proxyTable配置,第1张

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://outofmemory.cn/zaji/586429.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-04-12
下一篇 2022-04-12

发表评论

登录后才能评论

评论列表(0条)

保存