I'm using Spring 4.3.10.RELEASE and I have the current CORS configuration that I found in Spring security CORS Filter
@Bean
CorsConfigurationSource corsConfigurationSource() {
final CorsConfiguration configuration = new CorsConfiguration();
configuration.setAllowedOrigins(Collections.singletonList("https://google.com"));
configuration.setAllowedMethods(Arrays.asList("GET", "POST", "PUT", "DELETE"));
configuration.setAllowCredentials(true);
configuration.setAllowedHeaders(Arrays.asList("Authorization", "Cache-Control", "Content-Type"));
final UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
source.registerCorsConfiguration("/**", configuration);
return source;
}
If I use:
configuration.setAllowedOrigins(Collections.singletonList("*"));
I can do requests to my API from any site (as expected), but if I try to insert a site or two and request something from those sites, the "missing Access-Control-Allow-Origins" warning appears:
Pedido de origem cruzada bloqueado: A política da mesma origem não permite a leitura do recurso remoto em https://localhost:8241/foo/. (Motivo: cabeçalho CORS 'Access-Control-Allow-Origin' em falta).
TypeError: NetworkError when attempting to fetch resource.
Is it something missing for this case?