Springboot ‘Access-Control-Allow-Origin‘ header is present on the requested resource

spring跨域问题解决

@Configuration
public class CorsConfig implements WebMvcConfigurer {
    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")
                .allowedHeaders("*")
                .allowedMethods("*")
                .allowedOriginPatterns("*")
                .allowCredentials(true)
                .maxAge(3600);
    }
}

你可能感兴趣的:(springboot,spring,boot,java)