Skip to content

Instantly share code, notes, and snippets.

@nelsondspy
Created October 11, 2018 14:26
Show Gist options
  • Save nelsondspy/ca426f42e31a9c5ea836c4e353a0b513 to your computer and use it in GitHub Desktop.
Save nelsondspy/ca426f42e31a9c5ea836c4e353a0b513 to your computer and use it in GitHub Desktop.
@Bean
public CorsFilter corsFilter() {
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
CorsConfiguration config = new CorsConfiguration();
config.setAllowCredentials(true);
config.addAllowedOrigin("*");
config.addAllowedHeader("*");
config.addAllowedMethod("OPTIONS");
config.addAllowedMethod("PATCH");
config.addAllowedMethod("GET");
config.addAllowedMethod("POST");
config.addAllowedMethod("PUT");
config.addAllowedMethod("DELETE");
source.registerCorsConfiguration("/**", config);
return new CorsFilter(source);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment