Я использую архитектуру микросервисов, которые используют весеннюю загрузку и Zuul с angular 7 впереди, и я хочу настроить логин через facebook. Я добавляю фильтр Cors в ZuulFilter следующим образом
@EnableZuulProxy
@Slf4j
public class CorsCustomFilter {
@Bean
public CorsFilter corsFilter() {
final UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
final CorsConfiguration config = new CorsConfiguration();
config.setAllowCredentials(true);
config.addAllowedOrigin("*");
config.addAllowedHeader("*");
config.addAllowedMethod("OPTIONS");
config.addAllowedMethod("HEAD");
config.addAllowedMethod("GET");
config.addAllowedMethod("PUT");
config.addAllowedMethod("POST");
config.addAllowedMethod("DELETE");
config.addAllowedMethod("PATCH");
source.registerCorsConfiguration("/**", config);
return new CorsFilter(source);
}
}`
here my design:
1- Angular App calls auth-ser with Http request through api_gateway
2- Auth-server try to call Facebook and here my api_gateway received a 302 http code which means a redirection and the error of missing Access-Control-Allow-Origin in header appears
But it doesn't work, and I get this error
I get this message Access to XMLHttpRequest at 'facebook.com/v2.5/dialog/…****' (redirected from 'localhost:4200/apiGateway/auth-server/api/connect/facebook') from origin 'localhost:4200' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource
any one have an idea ?