跨域配置

2020-03-23  本文已影响0人  jeanzy
devServer: {
        open: true, //是否自动弹出浏览器页面
        host: "localhost", 
        port: 8080,
        proxy: {
            '/apis': {
                target: 'http://efmudc.homewell.com.cn/platformapi',  // target host
                ws: true,  // proxy websockets 
                changeOrigin: true,  // needed for virtual hosted sites
                pathRewrite: {
                    '^/apis': ''  // rewrite path
                },
              '/ipa': {
                target: 'http://47.99.60.167:8081/api/test',
                ws: true,  
                changeOrigin: true,
                pathRewrite: {
                    '^/ipa': ''
                }
              }
            },
        }
    }
axios.default.baseUrl = "/apis";
axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
axios.defaults.withCredentials=true
Vue.prototype.$axios = axios;
axios.interceptors.response.use(res=>res.data);

请求的时候
let publicKey = await axios.get('/apis/getPublicKey')

上一篇下一篇

猜你喜欢

热点阅读