org.springframework.web.cors.reactive.CorsWebFilter Java Examples

The following examples show how to use org.springframework.web.cors.reactive.CorsWebFilter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WebConfig.java    From influx-proxy with Apache License 2.0 6 votes vote down vote up
@Bean
CorsWebFilter corsFilter() {
    CorsConfiguration config = new CorsConfiguration();
    config.setAllowCredentials(true);
    config.addAllowedOrigin("*");
    config.addAllowedHeader("*");
    config.addAllowedMethod("*");
    UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
    source.registerCorsConfiguration("/**", config);
    return new CorsWebFilter(source);
}
 
Example #2
Source File: CorsConfig.java    From microservices-platform with Apache License 2.0 6 votes vote down vote up
@Order(Ordered.HIGHEST_PRECEDENCE)
@Bean
public CorsWebFilter corsFilter() {
    CorsConfiguration config = new CorsConfiguration();
    // cookie跨域
    config.setAllowCredentials(Boolean.TRUE);
    config.addAllowedMethod(ALL);
    config.addAllowedOrigin(ALL);
    config.addAllowedHeader(ALL);
    // 配置前端js允许访问的自定义响应头
    config.addExposedHeader("setToken");

    UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(new PathPatternParser());
    source.registerCorsConfiguration("/**", config);

    return new CorsWebFilter(source);
}
 
Example #3
Source File: CrossDomainConfiguration.java    From momo-cloud-permission with Apache License 2.0 6 votes vote down vote up
@Bean
public CorsWebFilter corsFilter() {
    CorsConfiguration config = new CorsConfiguration();
    // cookie跨域
    config.setAllowCredentials(Boolean.TRUE);
    config.addAllowedMethod(CorsConfiguration.ALL);
    config.addAllowedOrigin(CorsConfiguration.ALL);
    config.addAllowedHeader(CorsConfiguration.ALL);
    // 配置前端js允许访问的自定义响应头
    config.addExposedHeader("x-token");

    UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(new PathPatternParser());
    source.registerCorsConfiguration("/**", config);

    return new CorsWebFilter(source);
}
 
Example #4
Source File: GlobalCorsConfig.java    From mall-swarm with Apache License 2.0 5 votes vote down vote up
@Bean
public CorsWebFilter corsFilter() {
    CorsConfiguration config = new CorsConfiguration();
    config.addAllowedMethod("*");
    config.addAllowedOrigin("*");
    config.addAllowedHeader("*");

    UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(new PathPatternParser());
    source.registerCorsConfiguration("/**", config);

    return new CorsWebFilter(source);
}
 
Example #5
Source File: CorsConfig.java    From sophia_scaffolding with Apache License 2.0 5 votes vote down vote up
@Bean
public CorsWebFilter corsFilter() {
    CorsConfiguration config = new CorsConfiguration();
    config.addAllowedMethod("*");
    config.addAllowedOrigin("*");
    config.addAllowedHeader("*");

    UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(new PathPatternParser());
    source.registerCorsConfiguration("/**", config);

    return new CorsWebFilter(source);
}
 
Example #6
Source File: CorsConfig.java    From sophia_scaffolding with Apache License 2.0 5 votes vote down vote up
@Bean
public CorsWebFilter corsFilter() {
    CorsConfiguration config = new CorsConfiguration();
    config.addAllowedMethod("*");
    config.addAllowedOrigin("*");
    config.addAllowedHeader("*");

    UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(new PathPatternParser());
    source.registerCorsConfiguration("/**", config);

    return new CorsWebFilter(source);
}
 
Example #7
Source File: CorsConfig.java    From sophia_scaffolding with Apache License 2.0 5 votes vote down vote up
@Bean
public CorsWebFilter corsFilter() {
    CorsConfiguration config = new CorsConfiguration();
    config.addAllowedMethod("*");
    config.addAllowedOrigin("*");
    config.addAllowedHeader("*");

    UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(new PathPatternParser());
    source.registerCorsConfiguration("/**", config);

    return new CorsWebFilter(source);
}
 
Example #8
Source File: SecurityConfiguration.java    From java-microservices-examples with Apache License 2.0 5 votes vote down vote up
@Bean
CorsWebFilter corsWebFilter() {
    CorsConfiguration corsConfig = new CorsConfiguration();
    corsConfig.setAllowedOrigins(List.of("*"));
    corsConfig.setMaxAge(3600L);
    corsConfig.addAllowedMethod("*");
    corsConfig.addAllowedHeader("*");

    UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
    source.registerCorsConfiguration("/**", corsConfig);

    return new CorsWebFilter(source);
}
 
Example #9
Source File: HttpIT.java    From vertx-spring-boot with Apache License 2.0 5 votes vote down vote up
@Bean
public CorsWebFilter corsWebFilter() {
    CorsConfiguration config = new CorsConfiguration();

    config.addAllowedOrigin("http://snowdrop.dev");
    config.addAllowedHeader("TEST");
    config.addAllowedMethod(HttpMethod.POST);
    config.setMaxAge(1000L);

    UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
    source.registerCorsConfiguration("/", config);

    return new CorsWebFilter(source);
}
 
Example #10
Source File: CorsWebFluxCfg.java    From streaming-file-server with MIT License 5 votes vote down vote up
@Bean
public CorsWebFilter corsWebFilter() {
  val corsConfig = new CorsConfiguration();
  corsConfig.addAllowedOrigin(ALLOWED_ORIGIN);
  corsConfig.addAllowedMethod(ALLOWED_METHODS);
  corsConfig.addAllowedHeader(ALLOWED_HEADERS);
  corsConfig.setMaxAge(MAX_AGE);

  val source = new UrlBasedCorsConfigurationSource();
  source.registerCorsConfiguration("/**", corsConfig);

  return new CorsWebFilter(source);
}
 
Example #11
Source File: CorsWebFilterConfig.java    From tutorials with MIT License 5 votes vote down vote up
@Bean
CorsWebFilter corsWebFilter() {
    CorsConfiguration corsConfig = new CorsConfiguration();
    corsConfig.setAllowedOrigins(Arrays.asList("http://allowed-origin.com"));
    corsConfig.setMaxAge(8000L);
    corsConfig.addAllowedMethod("PUT");
    corsConfig.addAllowedHeader("Baeldung-Allowed");

    UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(new PathPatternParser());
    source.registerCorsConfiguration("/**", corsConfig);

    return new CorsWebFilter(source);
}
 
Example #12
Source File: CorsConfig.java    From codeway_service with GNU General Public License v3.0 4 votes vote down vote up
@Bean
public CorsWebFilter corsFilter(){
	UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(new PathPatternParser());
	source.registerCorsConfiguration("/**", buildConfig());
	return new CorsWebFilter(source);
}
 
Example #13
Source File: CorsConfig.java    From codeway_service with GNU General Public License v3.0 3 votes vote down vote up
@Bean
public CorsWebFilter corsFilter(){
	UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(new PathPatternParser());
	source.registerCorsConfiguration("/**", buildConfig());
	return new CorsWebFilter(source);
}