美文网首页Vue
Vue 设置 proxy 代理 - Vue

Vue 设置 proxy 代理 - Vue

作者: survivorsfyh | 来源:发表于2020-05-19 16:46 被阅读0次

开发中接口调试经常会遇到接口调试抛出跨域问题,在 vue.config.js 中设置如下 proxy 即可:
注:当前 Vue 版本为 @vue/cli 4.3.1

// vue.config.js 文件下
module.exports = {
    publicPath : '',
    devServer : {
        proxy : {
            '^/osce2' : {
                target : 'http://192.168.8.187:8005', // 设置接口域名和端口号
                changeOrigin : true, // 跨域
                pathRewrite : {
                    '^/osce2' : '/osce2'
                }
            },
        }
    }
};


以上便是此次分享的全部内容,希望能对大家有所帮助!

相关文章

网友评论

    本文标题:Vue 设置 proxy 代理 - Vue

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