Vue cli4.0 代理配置

proxy: {
            '/service': {
                target: 'http://192.168.40.243:3000/', //对应自己的接口
                changeOrigin: true,
                ws: true,
            },
            // '/page':{
            //     target: 'http://192.168.0.167:9810',
            //     changeOrigin: true,
            //     ws:true
            // },
            // '/table':{
            //     target: 'http://192.168.0.167:9810/',
            //     changeOrigin: true,
            //     ws:true
            // },
            '/api':{
                target: 'http://192.168.0.167:9810',
                changeOrigin: true,
                pathRewrite: {
            '^/api':'/api', // 这种接口配置出来实际请求接口 http://192.168.0.167:9810/api/login,
            '^/api': '/' } },// 这种接口配置出来实际请求接口 http://192.168.0.167:9810/login, (后端大爷接口没有同意前缀时可以这样处理,前端请求的时候自己加api 前缀,避免每一个不同的前缀要重写一遍)          
}

  

猜你喜欢

转载自www.cnblogs.com/winyh/p/11926893.html