vue3.0代理方法


在根目录下新建一个文件夹vue.config.js,注意根目录是,而不是src路径,然后请求

 

 

 

module.exports = {
  lintOnSave:false, 
  devServer: {
    overlay:{
      warning:false,
      errors:false
  },
    proxy: { 
      '/api': {
        // target: 'http://172.16.15.27:8081',
        target: 'http://172.16.15.159:8080/', 
        secure: false, // false为http访问,true为https访问
        changeOrigin: true, // 跨域访问设置,true代表跨域
        ws: true,
        pathRewrite: { // 路径改写规则
          '^/api': '' // 以/proxy/为开头的改写为''
        }
      }
    }
  }
}

  


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM