vue解决前后端跨域问题

1/在config中index.js中

  //解决跨域
    proxyTable: {
      '/api': {  //使用"/api"来代替"http://f.apiplus.c" 
          target: 'http://127.0.0.1:8005', //你需要访问的源地址不需要加后缀
          changeOrigin: true, //改变地址 
          pathRewrite: { 
            '^/api': '', //重写127.0.0.1:8005 路径 为api
            } 
        }

    },

注意修改备注后,需要重新使用 npm run dev 打包编译项目使配置生效

访问:

 

猜你喜欢

转载自www.cnblogs.com/Rivend/p/11927388.html