Webpack dev server failed to configure reverse proxy

failed to configure the reverse proxy using webpack dev server. After I failed to configure the proxy in the project, I immediately downloaded a new vue cli to configure it, but it still didn"t work

.
  1. proxy Settings ( config/index.js )
    proxyTable: {
      "/api": {
        target: "http://xxx.xxx.xxx.xxx:81",
        changeOrigin: true,
        secure: false
      }
    },
  1. request
      const options = {
        news_type: 1,
        news_title: "",
        news_desc: "1111111111",
        news_url: "",
        images_url: "",
        id: 0
      }
      axios({
        method: "post",
        url: "/api/news/saveNews",
        data: options
      }).then(res => {
        if (res.data.status === "success") {
          this.$Message.success("")
        }
      })

3. Result


to delegate to http://xxx.xxx/news/saveNews, you need to rewrite the beginning / api as an empty string.

pathRewrite: {
    '^/api': ''
}

proxyTable: {
      '/api'  : {
                target      : 'http://192.168.125.174:81',
                changeOrigin: true,
                pathRewrite : {
                    '^/api': ''
                }
      }
    },
Menu