跨域代理设置

// 开启代理服务器 (方式1)
    //   (1只能配置一个代理)
    //   (2 不能控制是否会走代理)
    // devServe:{
    //     proxy:'http://localhost:5000'
    // }
   // 开启代理服务器 (方式2)
    devServe:{
        proxy: {
            //  '/api' : 请求前缀
          '/api':{
              target:'http://localhost:5000',
              // 请求的时候 去掉前缀
              pathRewrite:{
               '^/api':''  
              },
            //   ws:true,   // 用于支持 websocket
            //   changeOrigin:true  // 用于控制请求头中的 host 值
          },
          '/demo':{
            target:'http://localhost:5001',
            // 请求的时候 去掉前缀
            pathRewrite:{
             '^/demo':''  
            },
          //   ws:true,   // 用于支持 websocket
          //   changeOrigin:true  // 用于控制请求头中的 host 值
        },
       
        }
    }
posted @ 2022-03-12 22:42  13522679763-任国强  阅读(171)  评论(0)    收藏  举报