vue配置proxyTable遇到的坑:[HPM] Error occurred while trying to proxy request
先来看看错误的写法:
proxyTable: {
'/api': {
target: 'localhost:8081',//设置你调用的接口域名和端口号
changeOrigin: true, //跨域
pathRewrite: {
'^/api': '/'
}
}
实际使用过程中会发现[HPM] Error occurred while trying to proxy request。
解决办法
改成target: ‘http://localhost:8081’!!
proxyTable: {
'/api': {
target: 'http://localhost:8081',//设置你调用的接口域名和端口号
changeOrigin: true, //跨域
pathRewrite: {
'^/api': '/'
}
}
然后就可以了。