.
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
package konturai.kz.api_gateway.configuration;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.cors.CorsConfiguration;
|
||||
import org.springframework.web.cors.reactive.CorsWebFilter;
|
||||
import org.springframework.web.cors.reactive.UrlBasedCorsConfigurationSource;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@Configuration
|
||||
public class CorsConfig {
|
||||
|
||||
@Bean
|
||||
public CorsWebFilter corsWebFilter() {
|
||||
|
||||
CorsConfiguration corsConfig = new CorsConfiguration();
|
||||
corsConfig.setAllowedOrigins(Arrays.asList(
|
||||
"https://konturai.kz",
|
||||
"http://localhost:5173" // Добавьте все нужные вам origin
|
||||
));
|
||||
corsConfig.setMaxAge(3600L);
|
||||
corsConfig.setAllowedMethods(Arrays.asList("GET", "POST", "PUT", "DELETE", "OPTIONS"));
|
||||
corsConfig.addAllowedHeader("*");
|
||||
corsConfig.setAllowCredentials(true);
|
||||
|
||||
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
|
||||
source.registerCorsConfiguration("/**", corsConfig);
|
||||
|
||||
return new CorsWebFilter(source);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user