前端
添加vue.config.js文件
【【4k小白到全栈】进阶课好看登录页面Vue3+Ts+Pinia+Axios+Vue Rouyer+SpringBoot2.7+Mybatis Plus前后端分离】https://www.bilibili.com/video/BV1x14y1Z74z?p=26&vd_source=da9319adec9f5f92ccc22db2f6108195
后端
response.setContentType("application/json;charset=utf-8"); response.setCharacterEncoding("UTF-8"); /* 设置响应头允许ajax跨域访问*/ response.setHeader("Access-Control-Allow-Origin", "*"); //允许所有来源访同 /* 设置请求头信息*/ response.addHeader("Access-Control-Allow-Headers", "Origin,X-Requested-With,Content-Type,Accept"); //////////////////// response.addHeader("Access-Control-Allow-Method","POST,GET");//允许访问的方式 ////////////////////////// /* 星号表示所有的异域请求都可以接受 */ response.setHeader("Access-Control-Allow-Headers", "GET,POST");标签:Control,axios,跨域,Access,vue,Allow,response From: https://www.cnblogs.com/zhangsai/p/17658791.html