2020-11-07 14:13:56 +04:00
|
|
|
package ru.ulstu.configuration;
|
2018-02-22 22:47:45 +04:00
|
|
|
|
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
|
import org.springframework.web.cors.CorsConfiguration;
|
|
|
|
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
|
|
|
|
import org.springframework.web.filter.CorsFilter;
|
|
|
|
|
|
|
|
@Configuration
|
|
|
|
class ControllersConfiguration {
|
|
|
|
@Bean
|
|
|
|
public CorsFilter corsFilter() {
|
|
|
|
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
|
|
|
|
CorsConfiguration config = new CorsConfiguration();
|
|
|
|
config.setAllowCredentials(true);
|
|
|
|
config.addAllowedOrigin("*");
|
|
|
|
config.addAllowedHeader("*");
|
|
|
|
config.addAllowedMethod("GET");
|
|
|
|
config.addAllowedMethod("POST");
|
|
|
|
config.addAllowedMethod("DELETE");
|
|
|
|
source.registerCorsConfiguration("/**", config);
|
|
|
|
return new CorsFilter(source);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|