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

Posted ahuo

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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‘,//重写,
          }
      }
    },


} }

  

以上是关于Vue报错:OPTIONS 405 Method Not Allowed以及CORS跨域错误的主要内容,如果未能解决你的问题,请参考以下文章