The problem

To solve

Add configuration file crossconfig.java to Springboot:

@Configuration
public class CrossConfig  implements WebMvcConfigurer {
    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")
                .allowCredentials(true)
                .allowedMethods("POST", "GET", "PUT", "OPTIONS", "DELETE")
                .maxAge(3600)
                .allowedOrigins("*");
    }
}
Copy the code