Skip to content

Instantly share code, notes, and snippets.

@Guvenir
Created March 12, 2016 13:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Guvenir/9111c21b2e9749f6f82d to your computer and use it in GitHub Desktop.
Save Guvenir/9111c21b2e9749f6f82d to your computer and use it in GitHub Desktop.
@Configuration
public class RestConfiguration {
@Bean
public CorsFilter corsFilter() {
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
CorsConfiguration config = new CorsConfiguration();
config.setAllowCredentials(true); // you USUALLY want this
config.addAllowedOrigin("*");
config.addAllowedHeader("*");
config.addAllowedMethod("GET");
config.addAllowedMethod("PUT");
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