zl程序教程

您现在的位置是:首页 >  前端

当前栏目

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

Vue错误跨域 报错 以及 not method Allowed
2023-09-14 08:58:28 时间

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

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

 

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


} }