vue配置proxyTable遇到的坑:[HPM] Error occurred while trying to proxy request

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': '/'       
        }
      }

然后就可以了。


版权声明:本文为qq_19289851原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。