Vue报错:OPTIONS 405 Method Not Allowed以及CORS跨域错误

前端增加代理解决,这个其实应该后端解决的

  • 修改config/index.js(基于Vue-CLI2)
  • 增加proxyTable

 

module.exports = {
  dev: {
    // proxyTable: proxyConfig.proxyList, // 无效,不使用,20190422
    proxyTable: {
      '/api': {
          target: 'http://localhost:8830',//后端接口地址
          changeOrigin: true,//是否允许跨越
          pathRewrite: {
              '^/api': '/api',//重写,
          }
      }
    },


} }

  

posted @ 2020-03-06 11:50  ahuo  阅读(4410)  评论(0编辑  收藏  举报