Vue

Vue 设置 proxy 代理 - Vue

2020-05-19  本文已影响0人  survivorsfyh

开发中接口调试经常会遇到接口调试抛出跨域问题,在 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'
                }
            },
        }
    }
};


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

上一篇 下一篇

猜你喜欢

热点阅读