Advertisement

基于Vue和Spring Security的前后端交互如何解决跨域问题

阅读量:

问题复现分析

复制代码
    Access to XMLHttpRequest at 'http://localhost:8081/login' from origin 'http://localhost:8080' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: It does not have HTTP ok status.
    
    
      
    
在这里插入图片描述

问题根源分析

导致这一问题的主要原因在于后端代码中未正确设置跨域相关配置,或者最初阶段我对跨域的设置方式并不了解。在后端开发过程中,我采用了Spring Boot框架结合Spring Security以及Jwt技术进行实现。在初期阶段,我进行了以下配置:

复制代码
    public class AccessControlAllowOriginFilter implements WebMvcConfigurer {

全部评论 (0)

还没有任何评论哟~