Vue Cli3.x 配置跨域请求

vue.config.js

module.exports = {
    baseUrl:'/', //根路径
    //outputDir:'dist'    //构建输出目录
    assetsDir:'assets',    //静态资源目录
    lintOnSave: false,      //是否开启eslint保存检测,有效值:true || false || 'error'开启后语法要求很严谨
    devServer:{
        open: true,         //启动项目是否自动打开主页
        host:"localhost",   //项目访问地址
        port:8080,          //端口号
        https: false,       //https协议
        hotOnly: false,     //热更新
        proxy:{
            //配置跨域
            '/api':{
                target:'http://localhost:8000',
                ws:true,
                changeOrigin: true,
                pathRewrite: {
                    '^/api': ''
                }

            }
        }
    }
};
Last modification:May 26th, 2019 at 10:45 am
If you think my article is useful to you, please feel free to appreciate

One comment

  1. xinggevip

    太难了!我真的太难了>﹏<

Leave a Comment