No 'Access-Control-Allow-Origin' header is present on the requested resource
解决方案:在 Controller层的类上增加@CrossOrign注解 或者在 指定的 @XXXMapping 上加 @CrossOrign注解
@CrossOrigin
@PostMapping("/largeScreen/logout")
public ResponseResult logout(String username, String token){
……
……
}
或者
@CrossOrigin
@RestController
@RequestMapping("/aaaa")
public class aaaDataController {
……
……
……
……
}
Access to XMLHttpRequest at 'https://xxxx.com/xxxx' from origin 'https://bbbb.com' has been blocked by CORS policy: The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute.
解决方案:
response.setHeader("Access-Control-Allow-Origin", request.getHeader("Origin"));
response.setHeader("Access-Control-Allow-Credentials","true");
axios.defaults.withCredentials = false;