保洁阿姨
50+年前端设计经验
悠悠博客
usuuu.com
保洁阿姨
50+年前端设计经验
/**
* web项目配置类
*/
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
.allowedOriginPatterns("*")
.allowedMethods("GET", "POST", "PUT", "DELETE")
.allowedHeaders("*")
.allowCredentials(true)
.maxAge(3600)
.exposedHeaders("Authorization");
}
@Bean
public FilterRegistrationBean<CorsFilter> corsFilter() {
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
CorsConfiguration config = new CorsConfiguration();
config.addAllowedOriginPattern("*");
config.addAllowedHeader("*");
config.addAllowedMethod("*");
config.setAllowCredentials(true);
config.setMaxAge(3600L);
source.registerCorsConfiguration("/**", config);
FilterRegistrationBean<CorsFilter> bean = new FilterRegistrationBean<>(new CorsFilter(source));
bean.setOrder(Ordered.HIGHEST_PRECEDENCE);
return bean;
}
}
站点公告
NoticeWeb前后端交流群:70888820
QQ号523179414(姓:郑)狗骗子,谢绝访问
热门文章
Host3139 次围观
3631 次围观
3879 次围观
1963 次围观
6666 次围观
4161 次围观
1854 次围观
1060 次围观