使用Spring Boot + Vue 做前后端分离项目搭建,实现登录时,出现跨域请求 Access to XMLHttpRequest at 'http://localhost/open/login' from origin 'http://localhost:8080' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. V…
在公司开发过程中,一个前后端分离的项目遇见了跨域的问题. 前端控制台报错:No 'Access-Control-Allow-Origin' header is present on the requested resource. 从经验得知:spring boot解决跨域问题.两种解决方法: 1.重写 WebMvcConfigurer 类,并注入到spring容器中: @Configuration public class CustomCorsConfiguration implements W…