webpack代理设置

  devServer: {
    // 端口配置
    port: 1888,
    // 友情提示:改完请重启项目才能生效!!!
    // 反向代理配置
    proxy: {
      "/api": {
        //将’/api‘请求转到代理请求’http://192.168.1.125/api‘
        target: "http://192.168.1.125",
        //此模式使用SockJS节点作为服务器,并在客户端上使用SockJS客户端。
        ws: true,
        /* 
          如果不想/api被传递,需要重写路径.
         e: /api/clsafe/test -> http://192.168.1.125/test
        */
        pathRewrite: {
          "^/api/clsafe": "/api/clsafe",
        },
      },
    },
  },

 

posted @ 2020-07-15 11:16  neo_o  阅读(1502)  评论(0编辑  收藏  举报

愿你的生活只有诗和远方