@Configuration
public class CorsConfig extends WebMvcConfigurer {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
.allowedOrigins("*")
.allowCredentials(true)
.allowedMethods("GET", "POST", "DELETE", "PUT","PATCH")
.maxAge(3600);
}
}
SpringBoot解决前后端全局跨域问题WebMvcConfigurer
原文:https://www.cnblogs.com/cchilei/p/14081003.html