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',//重写,
          }
      }
    },


} }

  

猜你喜欢

转载自www.cnblogs.com/ahuo/p/12425709.html