Search in sources :

Example 1 with CorsFilter

use of cn.taketoday.web.servlet.filter.CorsFilter in project today-infrastructure by TAKETODAY.

the class CorsFilterTests method setup.

@BeforeEach
public void setup() {
    config.setAllowedOrigins(Arrays.asList("https://domain1.com", "https://domain2.com"));
    config.setAllowedMethods(Arrays.asList("GET", "POST"));
    config.setAllowedHeaders(Arrays.asList("header1", "header2"));
    config.setExposedHeaders(Arrays.asList("header3", "header4"));
    config.setMaxAge(123L);
    config.setAllowCredentials(false);
    UrlBasedCorsConfigurationSource configSource = new UrlBasedCorsConfigurationSource();
    configSource.registerCorsConfiguration("/**", config);
    filter = new CorsFilter(configSource);
}
Also used : CorsFilter(cn.taketoday.web.servlet.filter.CorsFilter) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 2 with CorsFilter

use of cn.taketoday.web.servlet.filter.CorsFilter in project today-framework by TAKETODAY.

the class CorsFilterTests method setup.

@BeforeEach
public void setup() {
    config.setAllowedOrigins(Arrays.asList("https://domain1.com", "https://domain2.com"));
    config.setAllowedMethods(Arrays.asList("GET", "POST"));
    config.setAllowedHeaders(Arrays.asList("header1", "header2"));
    config.setExposedHeaders(Arrays.asList("header3", "header4"));
    config.setMaxAge(123L);
    config.setAllowCredentials(false);
    UrlBasedCorsConfigurationSource configSource = new UrlBasedCorsConfigurationSource();
    configSource.registerCorsConfiguration("/**", config);
    filter = new CorsFilter(configSource);
}
Also used : CorsFilter(cn.taketoday.web.servlet.filter.CorsFilter) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

CorsFilter (cn.taketoday.web.servlet.filter.CorsFilter)2 BeforeEach (org.junit.jupiter.api.BeforeEach)2