美文网首页
跨域配置

跨域配置

作者: jeanzy | 来源:发表于2020-03-23 19:48 被阅读0次
    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')

    相关文章

      网友评论

          本文标题:跨域配置

          本文链接:https://www.haomeiwen.com/subject/htlgyhtx.html